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 <[email protected]> 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'
> [user@debian7_x64:22] sudo: busybox whoami
> [user@debian7_x64:22] out: sudo: unable to resolve host debian7_x64
> [user@debian7_x64:22] out: sudo password:
> [user@debian7_x64:22] out: root
> [user@debian7_x64: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
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/fab-user
>



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

_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to