User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,428 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,572 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1624 | Replies: 2 | Solved
Reply
Join Date: Jun 2007
Location: Los Angeles, USA
Posts: 2
Reputation: le0pard13 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
le0pard13's Avatar
le0pard13 le0pard13 is offline Offline
Newbie Poster

Convert shell script for looping

  #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:
#!/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
Thanks in advance.
"Experience is that marvelous thing that enables you to recognize a mistake when you make it again." --F. P. Jones
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore, India
Posts: 535
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Rep Power: 4
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Convert shell script for looping

  #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
  10.  
Are you Agile.. ?
Reply With Quote  
Join Date: Jun 2007
Location: Los Angeles, USA
Posts: 2
Reputation: le0pard13 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
le0pard13's Avatar
le0pard13 le0pard13 is offline Offline
Newbie Poster

Solution Re: Convert shell script for looping

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:18 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC