| | |
Convert shell script for looping
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
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:
Thanks in advance.
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/bash # # purpose: to use rsync to synchronize the MirrorAgent.logs of PHD users # # create variables RSYNC="/usr/bin/rsync" ROpts="-az -e ssh" ADMIN="alatorre@cshs.org" SRC="cardenasv@awm2212a.csmc.edu:~/Library/Logs/MirrorAgent.log" DST="/Volumes/Data2/MA_logs/cardenasv/" theLog="/Library/Logs/mySync.log" # # sync MirrorAgent.log time $RSYNC $ROpts $SRC $DST >> $theLog # test to see if sync completed successfully if [ ! $? = 0 ]; then echo "MA_log SYNC NOT COMPLETED!!!" >> $theLog echo "MirrorAgent.log not synced!" | mail -s "MA log sync problem" $ADMIN fi exit 0 # end script
"Experience is that marvelous thing that enables you to recognize a mistake when you make it again." --F. P. Jones
Does this help ?
bash Syntax (Toggle Plain Text)
#!/bin/bash file_with_workstations_list=/tmp/input_list.txt while read workstation_name do #do you stuff with workstation_name echo "Read workstation name: " $workstation_name done < $file_with_workstations_list
Are you Agile.. ?
![]() |
Similar Threads
- How to su properly in a shell script (Shell Scripting)
- Linux Shell Script needs help writing program (Shell Scripting)
- Problem with variables in Windows shell script (Windows NT / 2000 / XP)
- Using find in a bash shell script (Shell Scripting)
- Shell Script for Gnome 2.6 Print Manager. (Shell Scripting)
Other Threads in the Shell Scripting Forum
- Previous Thread: shell script crontab
- Next Thread: script to email new ip
Views: 2233 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting





