11 comment

  1. If you want to fully parallelize the script you can wrap the ssh command in parentheses in order to execute in a subshell, I believe. That way the script doesn’t wait for the program to finish. I use this to dynamically test all the workstations in my lab (~150) to see which ones are up and running, so I can generate a machine list for a distributed MPICH program.

  2. Very nice script. I use(d?) to manually write a “for” loop every time I need to run the same command on multiple hosts.
    I’ve just modified your sample script, declaring another variable (COMMAND=$@) to use instead of “w”, so I can run
    ./dsh cat /etc/hosts to get the content of all servers’ /etc/hosts in my mailbox.

  3. i tested this script found not working when one of host is down ssh command does not proceed to next host

    please help

    Nitin

  4. Hi, the script is really help ful!! Thanks for this. I want to add one small things for the administrators / developers who want to execute a command only on the remote machine via ssh + shell script e.g ssh [email protected].0.2 ‘service httpd status’ ….if some one want to change the single quoted parameter…he has to defined that much variable and called each variable one by one as per his desire to form expected command…check this code

    #!/bin/sh
    INPUT="service"
    I2=$1
    #I2="httpd"
    I3=$2
    #I3="stop"
    for I in $INPUT
    do
    echo -e "----------------------------------------------n";
    for ip1 in $I2
    do
    for ip2 in $I3
    do
    ssh [email protected] $I $ip1 $ip2
    done
    done
    echo -e "----------------------------------------------n";
    done
  5. Nice article. Interesting subject.

    Just wanted to tip about fabric. Great tool for deployment / Installation / admin python scripts

Comments are closed.