This is an old thread, but just wanted to mention a clean, easy solution that I'm using - I just add an 'execute_at' method to the Capistrano DSL module and it's working fantastically.
https://gist.github.com/SteveBenner/7333298 On Tuesday, October 14, 2008 12:49:21 AM UTC-7, thomas.mery wrote: > > Thanks for the answers > > this clears things for me :) > > thomas > > On Oct 9, 8:22 pm, Lee Hambley <[email protected]> wrote: > > It is worth noting for the sake of completeness - although it's more > > of a Bash (or any shell) feature. > > > > That && will execute the following task only if the first one is > > successful. > > > > run "cd /path && ls -al" > > > > Wouldnt' run the ls command if it couldn't changedirectory.. which in > > this instance makes sense, the following would execute the bash > > commands in order until the end of the string. > > > > run "cd /path ; ls -al" > > > > Meaning that you can get away with not being able to changedirectory, > > or something. > > > > run <<-EOB > > > > if [ -d /path ]; > > then { > > cd /path; > > ls -al > > } > > fi; > > > > EOB > > > > Not the most useful hack in the world.. but it just ties in with what > > I'm working on on the documentation at the moment - so I mention it > > anyway :) > > On Oct 8, 2:56 pm, Jamis Buck <[email protected]> wrote: > > > > > Each run() is done in a subshell, so any changes made to your > > > session's state there are lost. Similarly, you cannot set environment > > > > variables that you want to persist across run calls, either. > > > > > The way to do this is to execute all the commands together in a single > > > > run() invocation: > > > > > run "cd /path && ls -al" > > > > > - Jamis > > > > > On Oct 8, 2008, at 2:45 AM, thomas.mery wrote: > > > > > > Hello all, > > > > > > Maybe this ha been answered before but could not find the solution > ... > > > > > > I simply want to changedirectorywithin a task to be able to run a > > > > command in a specificdirectory > > > > > > but it fails .... > > > > > > here is my test task : > > > > > > desc "TEST" > > > > task :test do > > > > > > run "cd /home/myaccount/mydirectory" > > > > run ""ls -al" > > > > > > end > > > > > > the output of the ls command will show the content of my user > > > >directory(the one I access when logging in) but not the content of > > > > thedirectoryI 'cd'ed into (output shows no error when issuing the cd > > > > command) > > > > > > I am probably missing something obvious here but I would really > > > > appreciate any insight :) > > > > > > thanks in advance > > > > > > thomas -- -- * You received this message because you are subscribed to the Google Groups "Capistrano" group. * To post to this group, send email to [email protected] * To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/capistrano?hl=en --- You received this message because you are subscribed to the Google Groups "Capistrano" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
