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

whats wrong with my ssh

Status
Not open for further replies.

meetramana

Programmer
Feb 2, 2005
57
US
Hi,

Datafile contains:
SERVER1
SERVER2
SERVER3
.....
......


Script:

while read server;
do
echo "checking for server $server"
ssh $server "ps -ef | grep processname"
done < Datafile

Isn't above script supposed to loop through all the servers in the Datafile.

right now it just runs for the first line and then stops.
any ideas what could be wrong.

it echos all the servers fine if I comment out the ssh line

 
Seems that ssh "eats" the standard input ...
You may try this (ksh-like):
for server in $(<Datafile)
do
echo "checking for server $server"
ssh $server "ps -ef | grep processname"
done

For bourne-like:
for server in `cat Datafile`

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
other solution:

while read server;
do
echo "checking for server $server"
ssh $server "ps -ef | grep processname" </dev/null
done < Datafile


HTH,

p5wizard
 
The other solution also works,
any idea why it was eating the standard input?
Thankyou
 
No, it just does...

rsh does that also.

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top