DSH POWER

    Sometimes we need to execute  a command on many aix systems at once, here comes the Distributed SHell utility .
    DSH can rely on RSH or SSH to connect to clients and execute commands , obviously nowadays RSH is deprecated so the choice must be SSH.For example a customer requested me to change the timezone format from Posix to Olson for some application compatibility issues .

    I wrote the node list in a text file called nodelist (yes i know , i have a lot of fantasy , LOL).
    I created a command file called , mhh let’s try to guess…. cmdfile

    #cat cmdfile.chgtz
    cp /etc/environment /etc/environment.$(date +%Y-%m-%d_%T)
    sed ‘s/^TZ.*$/TZ=NFT-1DFT,M3.5.0,M10.5.0/g’ /etc/environment > /etc/environment.new
    grep TZ /etc/environment.new
    mv /etc/environment.new /etc/environment
    echo $TZ

    and the shell script dsh_do.sh that do the stuff …reads the cmdfile and gives to it the nodelist as a parameter , one node at a time.

    #cat dsh_do.sh

    #!/usr/bin/ksh
    while read node; do dsh -n $node -e ./cmdfile.chgtz; done < nodelist

    Simply the command file makes a backup of the /etc/environment file , do the substitution with sed redirecting the output to a temp file . The temporary .new file is renamed to replace the original.
    This solution give me the flexibility to do what i want (specified in cmdfile) on the nodes i want (in nodelist)
    without visiting the clients.