Regarding the name env.cwd
If you want to preserve your initial local current working directory in env
use a name such as env.local_cwd rather than env.cwd. This is because the
value of env.cwd appears to be used by subsequent commands meaning that if
you run a remote command on Linux box from a local OS X lsystem, for example
and have saved your current working directory using env.cmd then you may
find yourself scratching your head at some peculiar error messages.
So this should work just fine in your fabfile:
env.local_cwd = os.getcwd()
but this might cause some head scratching at some point in time when
executing remote commands:
env.cwd = os.getcwd()
def test():
run('ls -al')
Example Output when run from local OS X host to remote Ubuntu
(10.0.1.198)box:
/Users/christophersteel/ontogeny2$ fab remote test
[[email protected]] Executing task 'test'
[[email protected]] run: ls -al
[[email protected]] out: /bin/bash: line 0: cd:
/Users/christophersteel/ontogeny2: No such file or directory
[[email protected]] out:
Fatal error: run() encountered an error (return code 1) while executing 'ls
-al'
Chris Steel
Fabric rocks. Thank you Jeff!
On Mon, Jul 11, 2011 at 4:35 PM, Jeff Forcier <[email protected]> wrote:
> On Mon, Jul 11, 2011 at 10:36 AM, Chris Steel <[email protected]>
> wrote:
> > I want to be able to run a single fab command, for example:
> >
> > fab combined_task
> >
> > so that a number of tasks take place on various target hosts with no
> > additional input required.
>
> What you need to do:
>
> * Use host_string instead of hosts. See the docs for a quick
> explanation of how/why this works and env.hosts doesn't:
> http://docs.fabfile.org/en/1.1.1/usage/library.html#connections
> * The gist is that env.hosts only works when set *before* the task is
> executed. Either at module level or by a non-remote-executing task run
> on the CLI prior, e.g. "fab setup realtask".
>
> What I need to do:
>
> * Add this to the FAQ :)
>
> -Jeff
>
> --
> Jeff Forcier
> Unix sysadmin; Python/Ruby engineer
> http://bitprophet.org
>
--
Christopher Steel
Voice of Access
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user