siavashgh |
01-31-2012 02:31 PM |
Data pipe lost when using ssh in shell script
Hi,
I want to do SSH on many different machines and then run some commands on them. A binary application randomly generates IP addresses and my script will take care of doing SSH.
Code:
$ ./IPGen.exe | ./myScript.sh
my script looks like this:
Code:
while read line; do
result1=$(ssh $line 'LinuxCommand1') &
result2=$(ssh $line 'LinuxCommand2') &
result3=$(ssh $line 'LinuxCommand3') &
wait;
echo "$result1 - $result2 - $result3";
done
The problems are:
1- The while loop ends after first round!!!
2- All variables (result1, result2, result3) are empty.
I tried to search the forum before posting but I really didn't know what should I search for?!
|