pydsh

Pydsh is a Python-based replication of pdsh that uses sshreader as the engine for parallelizing ssh tasks. It also attempts to format the output from commands for you in a easy to read manner. Below are some examples of how it can be used.

Warning

With pydsh v1.3 I have moved away from the argparse module in favor of the Click module. Some of the cli flags have changed.

Debugging

In pydsh v2.6 I added better logging support for both the pydsh script and the sshreader module which powers it. There are 4 levels of debugging available to you:

  • debug = pydsh:INFO

  • debug + verbose = pydsh:INFO + sshreader:INFO

  • debug + 2verbose = pydsh:DEBUG + sshreader:INFO

  • debug + 3verbose = pydsh:DEBUG + sshreader:DEBUG

Keep in mind that most people will probably only ever need the INFO levels of debugging. DEBUG levels may generate a lot of output and are generally used to find issues within the sshreader package itself.

Examples

Simplest form of pydsh [1]. Run a command and show the output of the commands as they complete: [2]

pydsh -w myhost[1-100].example.com 'uname -r'

Note

When using the --dshbak or --coalesce options, a progress bar will be shown to the user as jobs are processing.

Run a script file rather than a simple command on remote hosts:

pydsh -F -w myhost[1-100].example.com my_complex_script.sh

Note

At this time scripts must have the first line start with #! in order to be loaded and run as a script by pydsh.

Print output organized by host (similar to piping to dshbak command):

pydsh -D -w myhost[1-100].example.com 'uname -r'

Print output coalesced by host (similar to piping to dshbak -c command):

pydsh -C -w myhost[1-100].example.com 'uname -r'

Override ssh with a username/password combo:

pydsh -u myuser -P Password1234 -w myhost[1-100].example.com 'uname -r'

Override ssh with a username/password combo (but prompt for the password):

pydsh -u myuser -p -w myhost[1-100].example.com 'uname -r'

Run pydsh faster (uses multi-processing and multi-threading): [3]

pydsh --redline -w myhost[1-100].example.com 'uname -r'

Indices and tables