Convert shell script for looping

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2007
Posts: 2
Reputation: le0pard13 is an unknown quantity at this point 
Solved Threads: 0
le0pard13's Avatar
le0pard13 le0pard13 is offline Offline
Newbie Poster

Convert shell script for looping

 
0
  #1
Jun 6th, 2007
Situation: I have a working shell script on our file server (OSXS Tiger) to connect to a workstation, which is using a portable home directory (phd), and rsync a user's MirrorAgent.log. I'm not that strong of a scripter, but I would like to add other workstations to this script as they are converted to phd's so they can be checked to see if the phd is working as it should (another script down the line). I reason that I need to convert this script to loop through the workstation names. I'm looking for any helpful suggestions for how to do this:
Shell Scripting Syntax (Toggle Plain Text)
  1. #!/bin/bash
  2. #
  3. # purpose: to use rsync to synchronize the MirrorAgent.logs of PHD users
  4. #
  5. # create variables
  6. RSYNC="/usr/bin/rsync"
  7. ROpts="-az -e ssh"
  8. ADMIN="alatorre@cshs.org"
  9. SRC="cardenasv@awm2212a.csmc.edu:~/Library/Logs/MirrorAgent.log"
  10. DST="/Volumes/Data2/MA_logs/cardenasv/"
  11. theLog="/Library/Logs/mySync.log"
  12. #
  13. # sync MirrorAgent.log
  14. time $RSYNC $ROpts $SRC $DST >> $theLog
  15. # test to see if sync completed successfully
  16. if [ ! $? = 0 ]; then
  17. echo "MA_log SYNC NOT COMPLETED!!!" >> $theLog
  18. echo "MirrorAgent.log not synced!" | mail -s "MA log sync problem" $ADMIN
  19. fi
  20. exit 0
  21. # end script
Thanks in advance.
"Experience is that marvelous thing that enables you to recognize a mistake when you make it again." --F. P. Jones
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Convert shell script for looping

 
0
  #2
Jun 14th, 2007
Does this help ?
  1. #!/bin/bash
  2.  
  3. file_with_workstations_list=/tmp/input_list.txt
  4.  
  5. while read workstation_name
  6. do
  7. #do you stuff with workstation_name
  8. echo "Read workstation name: " $workstation_name
  9. done < $file_with_workstations_list
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 2
Reputation: le0pard13 is an unknown quantity at this point 
Solved Threads: 0
le0pard13's Avatar
le0pard13 le0pard13 is offline Offline
Newbie Poster

Re: Convert shell script for looping

 
0
  #3
Jun 14th, 2007
Yes, it does. This is exactly what I need. Thanks, much. :-)
"Experience is that marvelous thing that enables you to recognize a mistake when you make it again." --F. P. Jones
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum


Views: 2233 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Shell Scripting
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC