LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-15-2004, 07:08 PM   #1
huntz
Member
 
Registered: Sep 2003
Location: Aussie
Distribution: shlackoes
Posts: 38

Rep: Reputation: 15
help with script


Hi

Need some help with a script.

I'm basically mirroring an ftp with wget which in turn gets mirrored by another ftp. I know it's a bit messy but for security reasons it has to be done like this.

Anyway the ftp is constantly being updated with new files.

My wget script is running in a continuous loop. When it has finished downloading a file it the copies it to another folder for the other FTP server to download.


#!/bin/bash
while true
do
wget -m -nH ftp://userassword@ip.addy.com -P /var/ftp/pub/commnews/ftp -o /var/ftp/pub/commnews/scripts/report/report.txt
cp -r /var/ftp/pub/commnews/ftp/* /var/ftp/pub/commnews/ftpsync/
done
# End of script

The wget part is working fine. Its the cp part I'm having problems with.

Is there someway of specifying the cp command to use timestamps or something. Because at the moment everytime wget finishes the download it then copies everything from folder A to folder B. I only want it to copy the new files from folder A to folder B.

Any help much appreciated.

Ta
 
Old 07-15-2004, 07:20 PM   #2
huntz
Member
 
Registered: Sep 2003
Location: Aussie
Distribution: shlackoes
Posts: 38

Original Poster
Rep: Reputation: 15
hmm actually I think i worked it out. cp -ru should do it right?
 
Old 07-16-2004, 06:44 AM   #3
maxx
LQ Newbie
 
Registered: Jul 2004
Posts: 8

Rep: Reputation: 0
Smile

ya
 
Old 07-16-2004, 12:50 PM   #4
thegeekster
Member
 
Registered: Dec 2003
Location: USA (Pacific coast)
Distribution: Vector 5.8-SOHO, FreeBSD 6.2
Posts: 513

Rep: Reputation: 34
Re: help with script

Quote:
Originally posted by huntz
...The wget part is working fine. Its the cp part I'm having problems with.

Is there someway of specifying the cp command to use timestamps or something. Because at the moment everytime wget finishes the download it then copies everything from folder A to folder B. I only want it to copy the new files from folder A to folder B.

Any help much appreciated.

Ta
Use the '-a' switch if you want to preserve the timestamps, permissions and links (rather than following links) (same as using -dpR)..............Combine with the '-u' switch to only update while preserving timestamps and permissions:

cp -au




PS: For just a recursive copy, use the '-R' switch rather than the '-r' switch................From the cp manpage:
Quote:
-r
Copy directories recursively, copying any non-directories and non-symbolic links (that is, FIFOs and special files) as if they were regular files. This means trying to read the data in each source file and writing it to the destination. Thus, with this option, `cp' may well hang indefinitely reading a FIFO or /dev/tty. (This is a bug. It means that you have to avoid -r and use -R if you don't know what is in the tree you are copying. Opening an unknown device file, say a scanner, has unknown effects on the hardware.)
-R, --recursive
Copy directories recursively, preserving non-directories (see -r just above).

Last edited by thegeekster; 07-16-2004 at 01:04 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 04:19 AM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
creating shell script that executes as root regardless of who runs the script? m3kgt Linux - General 13 06-04-2004 10:23 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
linux 9 and java script error - premature end of script header sibil Linux - Newbie 0 01-06-2004 04:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration