fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] run commands in sub-shell?


From: Jeff Forcier
Subject: Re: [Fab-user] run commands in sub-shell?
Date: Sun, 10 Apr 2011 20:17:40 -0700

Fabric runs every command within a subshell by default, as documented
in the API docs for run and sudo:

    
http://docs.fabfile.org/en/1.0.1/api/core/operations.html#fabric.operations.run

You can verify whether this is lining up with what you need/want by
turning on debug output:

    http://docs.fabfile.org/en/1.0.1/usage/output_controls.html#debug-output



On Sun, Apr 10, 2011 at 4:29 PM, Mohamed Lrhazi <address@hidden> wrote:
> From looking at the code, in operations.py,it does not seem to be
> passing the command to a shell with -c argument, like in the example I
> gave from sudo man page.
>
> So the command would run as:
>
> sudo command
>
> and not
>
> sudo sh -c command
>
> so if my command has shell redirection or pipes, those would not apply
> to my command, but to the bash used to run sudo.. am I right?
>
>
>
> On Sun, Apr 10, 2011 at 6:14 PM, Christian Vest Hansen
> <address@hidden> wrote:
>> It already does this. With sudo(), the env.sudo_prefix is put in front
>> of the command constructed with env.shell (bash by default) and your
>> command line.
>>
>> On Sun, Apr 10, 2011 at 21:44, Mohamed Lrhazi <address@hidden> wrote:
>>> wouldn't it be better if run() and sudo() run commands in a subshell?
>>> as sudo man page says:
>>>
>>>
>>>  To make a usage listing of the directories in the /home partition.
>>> Note that this runs the commands in a sub-shell to make the cd and
>>> file redirection work.
>>>
>>>        $ sudo sh -c "cd /home ; du -s * | sort -rn > USAGE"
>>>
>>>
>>> Or this possible by setting some env variables?
>>>
>>>
>>> Thanks,
>>> Mohamed.
>>>
>>> _______________________________________________
>>> Fab-user mailing list
>>> address@hidden
>>> http://lists.nongnu.org/mailman/listinfo/fab-user
>>>
>>
>>
>>
>> --
>> Venlig hilsen / Kind regards,
>> Christian Vest Hansen.
>>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>



-- 
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org



reply via email to

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