Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'Here document' loop broken by rsh 1

Status
Not open for further replies.
Jun 22, 2000
6,317
AU
Hi,

Anyone know why the following script works as expected when simply echoing the 'rsh' command line, but stops after the first host in the list when the rsh is actually executed?

[tt]------------------------------- 8< ------------------------
#!/usr/bin/ksh

DEBUG_ECHO=echo

do_uptime ()
{
while read line
do
echo &quot;$line: \c&quot;
${DEBUG_ECHO} rsh $line uptime
done
}

do_uptime << HERE
hosta
hostb
hostc
HERE
------------------------------- 8< ------------------------[/tt]

Any help greatly appreciated.

Annihilannic.
 
is it anything to do with exit status?

you don't have one in your procedure, or rsh returning a bad status?

something like that. :)
 
Jad,

I would have thought that the success (or otherwise) of the subsequent 'read' command would have overwritten any exit status set by the 'rsh'?

Annihilannic.
 
if it gets a bad exit, then it remembers the bad exit, even if it gets a good one elsewhere ...
 
Jad,

I don't think it's as simple as that. After sticking in some debugging displays of the value of $? I confirmed that the rsh is actually returning 0, or success.

For some reason it looks like the pipe from the input data to the 'read line' is being broken (by the rsh?) somehow.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top