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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While loop!!!!

Status
Not open for further replies.

stupejohns

Technical User
Apr 17, 2003
4
0
0
GB
Hello,

I'm trying to construct a script that rsh to the hosts within the /etc/hosts file and issues a df -k command, it looks like this;

while (true)
do
read ip hostname rest
if [ "$ip" = "" ]; then
break
else
rsh $ip df -k
fi
done< hosts

Trouble is that after the first successful df -k, the loop starts again but passes a null string to the read which then breaks out of the loop. The hosts file has many more lines that need to be processed and there are no blank lines within the file.

when I substitute rsh $ip df -k with just an echo $ip $hostname the whole input file is processed, so could this be a problem with rsh ?????

Any help with this would be great!

Thanks

stupejohns
 
Yep, rsh breaks standard input somehow. Try rsh -n, or alternatively, read from another file descriptor.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top