fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] how to change present working directory?


From: Jeff Forcier
Subject: Re: [Fab-user] how to change present working directory?
Date: Mon, 13 Oct 2008 09:36:52 -0400

Hi Bryan,

Fabric (and similar tools) don't actually keep a persistent shell open
on the remote machine; instead, each call to run() invokes a single
remote command. As such, interactive shell session commands such as
'cd' don't make any sense; what happens is you're simply opening a
shell, cd-ing to /var/myapp, and then closing the shell.

I can't think of a single Unix command that actually cares what
directory you're in, however, save for poorly written scripts and such
that source files based on where you're executing from instead of
where the script itself is ;) so you should always be able to work
around this limitation.

In your case, going by what I'm seeing in 'git help clone', you should
be able to simply do:

    run('git clone git://myserver/foo.git /var/myapp/foo')

and that should create the new Git checkout/clone in /var/myapp/foo
(so the git folder would end up at /var/myapp/foo/.git, with the top
level of that Git repo at the same level).

Finally, apologies if this is obvious to you :) but you can also
"emulate" the usefulness of 'cd' by storing the directory name(s) you
wish to work in as Python vars or Fab vars in your Fabfile, and then
using them in your run commands to avoid repetition.

Regards,
Jeff

On Mon, Oct 13, 2008 at 8:32 AM, Bryan Berry <address@hidden> wrote:
> hey guys,
>
> I just started playing w/ Fabric, awesome tool! I am having trouble
> changing the working directory w/ run("cd /var/myapp") . I need to
> change the current directory before performing my code checkout w/ git.
>
> run("cd /var/myapp") works w/ out errors but all following run()
> commands operate in my /root directory
>
> Is there an easy way to change this? perhaps w/ the fab_shell variable?
>
> thanks again for the great tool. I may ask some basic questions as I am
> new to Python.
>
> --
> Bryan W. Berry
> Technology Director
> OLE Nepal, http://www.olenepal.org
>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]