LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   while loop failure due to ssh (https://www.linuxquestions.org/questions/programming-9/while-loop-failure-due-to-ssh-177749/)

hurny^ 05-04-2004 10:52 AM

while loop failure due to ssh
 
I am having trouble writing a ssh command within a while statement. The while statement is correct, but the use of ssh within it causes the loop to end prematurely.
Here is the code at present. Does anyone have any idea of the solution
p.s. hostmach.dat is a file listing all ip addresses on the LAN (i.e. each line = 192.168.200.13)

#!/bin/sh
# tcode 4/05/2004 13:27:42 4-05-2004 15:38:13
echo "start of file" > temp.dat
while read line
do ssh $line "assign/nodeip" >> temp.dat;
done < "hostmach.dat"

jim mcnamara 05-04-2004 03:00 PM

I think ssh invokes exec - this means you can't get back to the calling shell unless you go to a subprocess to run ssh.
As I remember something like this:

Code:

while read line
do
      (ssh $line "assign/nodeip" >> temp.dat)
done < "hostmach.dat"



All times are GMT -5. The time now is 08:29 PM.