Hi I have file name bonding with below entry:
testnode1 eth0
tetnode2 eth2
Now I'm writing a bash script do a loop using while to put that entry in to variable then use it to below command:
ssh $serv ifconfig | grep $nic
Problem is its exited to early after the first read " testnode1 " it does not execute the next line " testnod2"
Here is the whole code:
#!/bin/bash
cat bonding | while read line
do
serv=$(echo $line | awk '{print $1}')
nic=$(echo $line | awk '{print $2}')
echo $serv
ssh $serv ifconfig | grep $nic
done
output:
testnode1
eth0 Link encap:Ethernet HWaddr 00:0C:29:99:C0:CD
expected output
testnode1
eth0 Link encap:Ethernet HWaddr 00:0C:29:99:C0:CD
testnode2
eth2 Link encap:Ethernet HWaddr 00:0A:30:40:QB:A1
Can someone point me to my mistake, thanks