Rsync to an external list of URLs


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Rsync to an external list of URLs
# 1  
Old 09-25-2008
Rsync to an external list of URLs

I'm going to have a text file formatted something like this:

Code:
some_name http://www.someurl.com/
another_name http://www.anotherurl.com/
third_name http://www.thirdurl.com/

I need to write a script that can rsync from a file path I'll set, to each URL in the list.

Any ideas?
# 2  
Old 09-25-2008
Post what have you tried so far and where exactly are you stuck?

Please read https://www.unix.com/unix-dummies-que...om-forums.html before posting, especially 5 and 6.
# 3  
Old 09-25-2008
Re: the rules; it's not for homework, and I have searched but didn't find anything relating to this specific idea.

Frankly, I don't know where to start. I've been looking at Awk and at Bash itself, so far.
# 4  
Old 09-25-2008
First step is to read each address for file:
Code:
while read name URL
do
   # do something with that $URL but I don't belive you can rsync from url
done < url_file

.. and next you have to visit rsync and see what you can or you cannot do.
# 5  
Old 09-29-2008
OK, so I'm able to loop through the external file and read a line into a variable. (I'm working with Mac OS X.)

Code:
SRCURL="~/Desktop/listrsync/source/";
while read URL
do
	echo "$URL";
	echo "rsync -avz --dry-run $SRCURL $URL";
	rsync -avz --dry-run $SRCURL $URL;
done < ~/Desktop/listrsync/targets.txt

Within the targets.txt file, I have:

Code:
~/Desktop/listrsync/a/
~/Desktop/listrsync/b/
~/Desktop/listrsync/c/

When I run the script, it produces the output:

Code:
~/Desktop/listrsync/source/
~/Desktop/listrsync/a/
rsync -avz --dry-run ~/Desktop/listrsync/source/ ~/Desktop/listrsync/a/
~/Desktop/listrsync/b/
rsync -avz --dry-run ~/Desktop/listrsync/source/ ~/Desktop/listrsync/b/
~/Desktop/listrsync/c/
rsync -avz --dry-run ~/Desktop/listrsync/source/ ~/Desktop/listrsync/c/

As you'd said, the rsync command itself doesn't work when run from within the loop. I'm wondering, since I can get validly-formatted rsync commands from the output, is there a way to simply run them?

Maybe through piping?

Or a temp file?
# 6  
Old 09-29-2008
I just tried directing the output (valid rsync commands) to a temp file, and running the temp file as a script; and it worked. Is there a better way?
# 7  
Old 09-29-2008
Is there a way to get the line number from the while loop, or should I start a counter for that?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync Error: rsync: link_stat failed: No such file or directory (2)

I wish to copy all the files & folder under /web/Transfer_Files/data/ on mymac1 (Linux) to remote server mybank.intra.com (Solaris 10) /tmp/ location I am using Ansible tool synchronize module which triggers the unix rsync command as below:rsync --delay-updates -F --compress --archive --rsh=ssh... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Solaris

How can i list Solaris External storages?

Hi how can i list Solaris external storage's only, ie SAN, # for fs in `mount -p | egrep 'ufs|zfs|vxfs' | awk '{print $3}'`; do df -h $fs | sed 's/%//g' | grep -v capacity; done /dev/dsk/c2t5000C5003C31721Bd0s0 30G 18G 12G 61 /... (5 Replies)
Discussion started by: bentech4u
5 Replies

3. OS X (Apple)

Rsync for back up, external HD

Hello all! I am quite unsure with all options of rsync. Here my backup configuration: I am on Mac X (10.8) and want an exact copy of my HD to an external HD. I formatted the new USB drive with Mac OS extended (Journaled, Encrypted) and made in my shell the following command and got the... (9 Replies)
Discussion started by: marek
9 Replies

4. Shell Programming and Scripting

Trying to extract domain and tld from list of urls.

I have done a fair amount of searching the threads, but I have not been able to cobble together a solution to my challenge. What I am trying to do is to line edit a file that will leave behind only the domain and tld of a long list of urls. The list looks something like this: www.google.com... (3 Replies)
Discussion started by: chamb1
3 Replies

5. UNIX for Dummies Questions & Answers

rsync file list help

Is it possible to make rsync output a list of all the files transferred to a separate text file? If so how? I wondered if the --write-batch=FILE optionis what I need Thanks (1 Reply)
Discussion started by: barrydocks
1 Replies

6. Shell Programming and Scripting

Remove external urls from .html file

Hi everyone. I have an html file with lines like so: link href="localFolder/..."> link href="htp://..."> img src="localFolder/..."> img src="htp://..."> I want to remove the links with http in the href and imgs with http in its src. I'm having trouble removing them because there... (4 Replies)
Discussion started by: CowCow339
4 Replies

7. Web Development

Tricky mod_rewrite for clean urls problems when fetching external sources

Hi, I have problems with mod rewrite. I will try to describe... I want clean urls but fail to make it work propperly. Maybe I have problems, because the content displayed is fetched from my other site... There is a lot of stuff I already red about this, but somehow I can not find a solution... (2 Replies)
Discussion started by: lowmaster
2 Replies

8. UNIX for Advanced & Expert Users

Rsync building file list/catalog path/location

Where is the file list created by rsync when it says building file list ? (1 Reply)
Discussion started by: glev2005
1 Replies

9. Shell Programming and Scripting

finding and removing patterns in a large list of urls

I have a list of urls for example: Google Google Base Yahoo! Yahoo! Yahoo! Video - It's On Google The problem is that Google and Google are duplicates as are Yahoo! and Yahoo!. I'm needing to find these conical www duplicates and append the text "DUP#" in from of both Google and... (3 Replies)
Discussion started by: totus
3 Replies

10. UNIX for Dummies Questions & Answers

Rsync file list

Hello, I'm trying to utilize rsync to backup 7 gigs of approximately 10,000 files, from what I've read this should be no sweat. However subsequent syncs seem to build an entirely new file list and the process takes a great deal of time. Reading the man page I'm not sure if I need to specify a file... (3 Replies)
Discussion started by: hexaplus
3 Replies
Login or Register to Ask a Question