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

A looping teaser 2

Status
Not open for further replies.

AnotherAlan

Technical User
Feb 10, 2006
362
GB
A little tester, I can't work out why it does this;

I have a script that reads file partitions to ufsdump from a flat file. When I added another partiton to dump it fails to pick it up. If I change the loop to a for loop it works!

original: Works with one item in flat file. Doesn't work with two items or more in flat file.

cat /admin/backup/servername_backup_list | while read BACKUP_ITEM2
do
echo "---Starting UFSDUMP of servername:$BACKUP_ITEM2 at `date`" >> $logfile 2>&1
rsh servername "/usr/sbin/ufsdump 0fu backupserver:$TAPE $BACKUP_ITEM2" >> $logfile 2>&1
echo " " >> $logfile 2>&1
done


This works:

for part in `cat /admin/backup/servername_backup_list`; do
rsh servername "/usr/sbin/ufsdump 0fu backupserver:$TAPE $part" >> $logfile 2>&1
done

And for the UUOC police I could do this; but it doesn't work either.

while read part; do

rsh servername "/usr/sbin/ufsdump 0fu backupserver:$TAPE $part" >> $logfile 2>&1

done < /admin/backup/servername_backup_list

I'm confused, but guessing it must be to do with rsh somehow.
All help appreciated.
Alan
 
rsh is eating away at your stdin

cat /admin/backup/servername_backup_list | while read BACKUP_ITEM2
do
echo "---Starting UFSDUMP of servername:$BACKUP_ITEM2 at `date`" >> $logfile 2>&1
rsh servername "/usr/sbin/ufsdump 0fu backupserver:$TAPE $BACKUP_ITEM2" >> $logfile 2>&1
echo " " >> $logfile 2>&1 [red]</dev/null[/red]
done

or use rsh -n flag (see man page)


HTH,

p5wizard
 
Perfect. Much obliged for the quick and accurate response.
A start Sir.

Alan
 
You may try this:
Code:
while read part; do
  rsh servername "/usr/sbin/ufsdump 0fu backupserver:$TAPE $part" < /dev/null
done < /admin/backup/servername_backup_list >> $logfile 2>&1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV. You were just beaten to it there.
But a star for responding.

Thanks
Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top