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 change directory.. 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 change directory,
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 change directory within a task to be able to run a
> > command in a specific directory
>
> > 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
> > the directory I '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
>
>
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---