Slide 11
Slide 11 text
"Base" operations
● run(command, shell=True, pty=True,
combine_stderr=True, quiet=False,
warn_only=False, stdout=None, stderr=None)
this and sudo are the two most used functions in Fabric, because they actually execute
commands on the remote host (which is the whole point of Fabric). With run, you execute the
specified command as the given user. run returns the output from the command as a string
that can be checked for a failed, succeeded and return_code attribute. shell controls whether
a shell interpreter is created for the command. If turned off, characters will not be escaped
automatically in the command. Passing pty=False causes a psuedo-terminal not to be created
while executing this command; this can have some benefit if the command you are running
has issues interacting with the psuedo-terminal, but otherwise, it will be created by default. If
stderr from the command to be parsable separately from stdout, use combine_stderr=False
to indicate that. quiet=True will cause the command to run silently, sending no output to the
screen while executing. When an error occurs in Fabric, typically the script will abort and
indicate as such. You can indicate that Fabric need not abort if a particular command errors
using the warn_only argument. Finally, you can redirect where the remote stderr and stdout
redirect to on the local side. If you want the stderr to pipe to stdout on the local end, you
could indicate that with stderr=sys.stdout