Discussion:
[Fab-user] combine_stderr = False has no effect
Lee Hughes
2014-11-10 21:10:15 UTC
Permalink
Hi I'm new to Fabric and am having trouble separating stderr from stdout.
from fabric.api import *
env.host_string = 'localhost'
env.port = 22
env.username = 'myusername'
env.password = 'mypassword'
env.warn_only = True
result = run('somebadcommand')
[localhost] run: somebadcommand
[localhost] out: /bin/bash: somebadcommand: command not found
[localhost] out:

Warning: run() received nonzero return code 127 while executing
'somebadcommand'!
result.stdout
'/bin/bash: somebadcommand: command not found'
result.stderr
''
result = run('somebadcommand',combine_stderr=False)
[localhost] run: somebadcommand
[localhost] out: /bin/bash: somebadcommand: command not found
[localhost] out:

Warning: run() received nonzero return code 127 while executing
'somebadcommand'!
result.stdout
'/bin/bash: somebadcommand: command not found'
result.stderr
''

​I expected the second attempt to return stderr to result.stderr instead of
result.stdout​

Any help would be greatly appreciated.
Thanks-
Lee
Jeff Forcier
2014-11-11 04:46:19 UTC
Permalink
You probably also need to explicitly say 'pty=False' - see
http://docs.fabfile.org/en/1.10/usage/interactivity.html#combining-the-two
Post by Lee Hughes
Hi I'm new to Fabric and am having trouble separating stderr from stdout.
from fabric.api import *
env.host_string = 'localhost'
env.port = 22
env.username = 'myusername'
env.password = 'mypassword'
env.warn_only = True
result = run('somebadcommand')
[localhost] run: somebadcommand
[localhost] out: /bin/bash: somebadcommand: command not found
Warning: run() received nonzero return code 127 while executing
'somebadcommand'!
result.stdout
'/bin/bash: somebadcommand: command not found'
result.stderr
''
result = run('somebadcommand',combine_stderr=False)
[localhost] run: somebadcommand
[localhost] out: /bin/bash: somebadcommand: command not found
Warning: run() received nonzero return code 127 while executing
'somebadcommand'!
result.stdout
'/bin/bash: somebadcommand: command not found'
result.stderr
''
I expected the second attempt to return stderr to result.stderr instead of
result.stdout
Any help would be greatly appreciated.
Thanks-
Lee
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org
Lee Hughes
2014-11-11 16:53:15 UTC
Permalink
Adding pty=False to the run() arguments did the trick. Thanks much Jeff!

*Lee*

Loading...