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!

Attempting to use a while loop on a file.... 3

Status
Not open for further replies.

jdespres

MIS
Aug 4, 1999
230
US
I'm attempting to loop tru a two column file with 38 lines of data.....

1st column = CLIENT
2nd column = GRID

cat file | while CLIENT GRID
do
echo "**************** $GRID $CLIENT ****************"
ssh admin@$GRID /usr/local/avamar/bin/mccli activity show --name=$CLIENT
done

It processes the 1st line then dies.....

Any idea's?

Thanks.....

Joe Despres
 
Change your file descriptor like so:

Code:
while read -u 3 CLIENT GRID
do
echo "**************** $GRID $CLIENT ****************"
ssh admin@$GRID /usr/local/avamar/bin/mccli activity show --name=$CLIENT
done 3< file

Regards,
Chuck
 
WoW................

That worked!

Not sure why..... But it worked!

Thanks!

Joe Despres
 
Or, alternatively, ssh -n should also work.

The documentation of that option on the ssh man page will give you a clue why both solutions work; ssh grabs stdin from the controlling loop and gobbles up the rest of the input data.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top