fab-user
[Top][All Lists]
Advanced

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

Re: [Fab-user] combine_stderr is not separating stderr and stdout


From: Jeff Forcier
Subject: Re: [Fab-user] combine_stderr is not separating stderr and stdout
Date: Wed, 24 Feb 2016 13:42:00 -0800

You need to also make sure you set pty=False, otherwise the pseudo-tty
allocated for your remote command will be merging the two streams on
its end anyways.

See the docs which go into detail about the two settings & how they
intersect / why they exist:
http://docs.fabfile.org/en/1.10/usage/interactivity.html#combining-the-two

On Wed, Feb 24, 2016 at 12:01 PM, cruxpot <address@hidden> wrote:
> I'm having an issue getting run and sudo to separate the streams which is
> causing issues particularly where sudo presents a first time "lecture"
> banner or an error before it runs the command and produces expected output.
> In this case, the sudo error is a resolution error on a debian 7 host
> running 'whoami'. I have set env.combine_stderr globally (env set at
> beginning), "with settings" and as a kwargs argument for sudo(). Same
> result, everything goes to stdout no matter I do.
>
> combine_stderr: 'False'
> address@hidden:22] sudo: busybox whoami
> address@hidden:22] out: sudo: unable to resolve host debian7_x64
> address@hidden:22] out: sudo password:
> address@hidden:22] out: root
> address@hidden:22] out:
> cmd: 'sudo -S -p 'sudo password:'  bash -l -c "cd /tmp/tmpdir2 >/dev/null &&
> export PATH=\"\".:/tmp/tmpdir2:/bin:/usr/bin\"\" && whoami"' SUCCEEDED with
> return code: '0', output:
> sudo: unable to resolve host debian7_x64
>
>
> Return values (result.stdout and result.stderr) are:
>
> stdout: 'sudo: unable to resolve host debian7_x64
>
> root'
> stderr: ''
>
> The "unable to resolve host" should go into stderr and I have confirmed this
> manually on a shell that it is in fact stderr. Why is this not working? It
> causes parsing issues as I want to discard the error output. I know the box
> is misconfigured but that is on purpose (simply remove its host definition
> in /etc/hosts).
>
> Code:
>  with settings(combine_stderr=False):
>      logger.debug("combine_stderr: '%s'" % env.combine_stderr)
>      result = sudo(cmd, combine_stderr=False)
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> https://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]