Korn script to access multiple host and collect data

Hi, I'm newbie in Korn scripting as well as in Unix. I need to have a script to do the following.

1) ssh multiple hosts
-In my case, login credentials are not an issue as all keys authorized by default. Example of host IP (24.35.14.6, 24.35.14.7, 24.35.14.8, 24.35.14.9, 24.35.14.10)

2) do df -Ph | grep LR in every host and copy this line into /tmp/vvv. The line should be something like this. "hostname" : "df -Ph output"

3) After those lines, then append with this below.
"hostname" : "number of the line in this hostname"

4) Total number of df -Ph lines in all hostnames must be added above all the lines. Means the amount of total should be in first line.

Is this possible to do? Please help. And please brief in short sentence for every line of command as it may help me to know what the command does. I'm learning the script but I must do this task urgently. Your help is very much appreciated.......:):):slight_smile:

Expecting this ..

for i in hostlist.txt
do
        ssh $i "hostname ; df -Ph ; hostname : \$\(df -Ph | wc -l\)" >> /tmp/vvv
done
echo "$(wc -l < /tmp/vvv)" ; cat /tmp/vvv 
1 Like

Thanks Jayan. I will try this out and let you know the output. :slight_smile: