-
August 2nd, 2006, 10:17 PM
#1
why does ssh break a /bin/sh while loop?
I'm having trouble using ssh to execute a remote command inside a /bin/sh script. It executes just fine once, but it stops the loop execution there:
Code:
cat /home/guest/systems | \
while read line
do
ssh -l root $line "ls -alF /etc"
done
Other commands between the do and done work and won't kill the loop, but for some reason as soon as I add the ssh the loop dies. The ssh command isn't failing, so I don't think it's the return code for ssh that's killing the loop, but I don't know why it's dying. Anyone have any ideas on why this is happening and how to avoid it?
/* You are not expected to understand this. */
-
August 3rd, 2006, 03:52 PM
#2
bash, csh, ksh?
bash# for line in `cat /home/guest/systems`; do ssh -l root $line "ls -alF /etc" ; done
Seems to work fine
Edit: ah.. the 'normal' bourne shell brb
Hmm.. logic error? Pipe being connected to ssh instead of while?
The bash line above should work in sh too..
Oliver's Law:
Experience is something you don't get until just after you need it.
-
August 4th, 2006, 02:35 PM
#3
Thanks, SirDice. That worked. I'm thinking it was the pipe in combination with the ssh in my loop that killed it.
/* You are not expected to understand this. */
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|