neoluu
neoluu

Reputation: 39

How to hide/suppress fabric ssh command output to console?

Hide/suppress fabric 2.4.0 ssh command execution on remote servers

I read the fabric doc and tried the --no-pty but without success

I execute a bunch of commands on remote servers like below and it Would return the output of that command on my console.

ssh_connect.run("sudo /usr/openv/netbackup/bin/admincmd/bppllist -U -verbose -allpolicies | egrep '^Policy Name|Active' | awk '/Active.*yes/{print x};{x=$3}'")

I would like to hide\suppress the output of those commands. I would only like it to print stuff if i explicitly use the print() function. I am using fabric version 2.4.0

Upvotes: 1

Views: 3427

Answers (2)

schwarzbrot
schwarzbrot

Reputation: 303

I think you want to call run with "hide=True":

ssh_connect.run(your_command, hide=True)

See the documentation for the 'invoke' library:

Specify hide='out' (or 'stdout') to hide only the stdout stream, hide='err' (or 'stderr') to hide only stderr, or hide='both' (or True) to hide both streams.

Upvotes: 3

nmlq
nmlq

Reputation: 3154

just add &> /dev/null to your command

ssh_connect.run("sudo /usr/openv/netbackup/bin/admincmd/bppllist -U -verbose -allpolicies | egrep '^Policy Name|Active' | awk '/Active.*yes/{print x};{x=$3}' &> /dev/null")

Upvotes: 0

Related Questions