Simple Examples

  1. PyDSH
  2. PyDCP
  3. Host Group File

Practical Examples

  1. Mass Apt-Get
  2. SSH Key Management

Simple Pydsh Examples:

  1. Run uptime on Host1 and Host2:

    pydsh -n host1 -n host2 uptime
    or
    pydsh --node=host1 --node=host2 uptime
    or
    pydsh --node=host1-2 uptime

  2. Run df -h on the hosts from the all host group file:

    pydsh -a -- df -h
    or
    pydsh -a "df -h"

  3. Run uptime on hosts 192.168.0.1 to 192.168.0.254:

    pydsh -n 192.168.0.1-254 uptime

  4. Run uptime on hosts Node1 to Node10:

    pydsh -n Node1-10 uptime

  5. Run uptime on a host1, 192.168.0.1-100, and Node1-10:

    pydsh -n host1 -n 192.168.0.1-100 --node=Node1-10 uptime

  6. Run uptime as user other than current:

    pydsh --user=USER2 -n host1 uptime

  7. Run uptime as root:

    pydsh --user=root -a uptime
    or
    pydsh -s -a uptime
    or
    pydsh --sudo -a uptime

Simple Pydcp Examples:

  1. Copy one file to home directory on all remote hosts:

    pydcp -a --scp_mode=send --scp_local=./filename

  2. Copy one file to the /tmp/cache directory on all remote hosts:

    pydcp -a --scp_mode=send --scp_local=./filename --scp_remote=/tmp/cache/

Host Group File Example:

  1. Host files are stored in /usr/local/etc/pydsh/groups by default. The file format is for each host to be listed on aline by itself, for example:
    host01
    host02
    192.168.0.1
    192.168.0.2
    localhost
    server.domain.com

    The "-a" command line option is a shortcut to the all host group file. Any other host group file may be selected with the "--hostfile=" option.