Results 1 to 3 of 3
I'm working on a script that uses rsync to replicate data to a central storage site for dozens of remote offices. Each remote office has a server set up with ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-16-2005 #1
- Join Date
- Sep 2005
Capturing exit values and using a parameters file
I'm working on a script that uses rsync to replicate data to a central storage site for dozens of remote offices. Each remote office has a server set up with an rsync daemon running. I'm not using SSH because all of the traffic between these sites are on a private network so the rsync daemon is running in socket mode.
Currently the script looks something like:
#!/bin/bsh rsync -rvvv location_1::temp /tmp/loc_1/ rsync -rvvv location_2::temp /tmp/loc_2/ rsync -rvvv location_3::temp /tmp/loc_3/ ...
...what I really want to do is have this script loop through the locations (reading them from a file) and then have the script use the exit values from rsync to identify when a particular location fails. If a location fails, it would place the location into a error file that could be used to retry the locations automatically. I'm still learning shell scripting so any help would be appreciatted.
- 12-16-2005 #2
To cycle through a list of places, use a:
for foo in "$bar" do baz $foo done
To capture error codes, you can check the variable $? after each command.
- 12-16-2005 #3
- Join Date
- Apr 2005
if a file called links.txt contains only a list of links, one on each line, the following could help:
#! /bin/bash for link in `cat links.txt` do echo -n "testing $link..." if rsync -rvvv $link then echo "good" else echo "bad" fi done