Operating System - HP-UX
1748122 Members
3111 Online
108758 Solutions
New Discussion юеВ

Download files to local server using ftp script based on date.

 
SOLVED
Go to solution
Gopi Kishore m
Occasional Advisor

Download files to local server using ftp script based on date.

Hi,
I have written one ftp script which will download some files from ftp server and scheduled this in cron.
Daily this script will run and download the files to local server.
It is running successfully.

Now the problem is some times the source system is not placing the files in server due to some problem at their end.

As we dont know this our script is downloading the previous day files.

Please let me know how to check the modified date in ftp. So that I will check date then download the file.
5 REPLIES 5
Steven Schweda
Honored Contributor

Re: Download files to local server using ftp script based on date.

> I have written one ftp script [...]

To run on what?

uname -a

> Please let me know how to check the
> modified date in ftp. [...]

Uh, have you considered using a "dir"
("LIST") command?

You might look into wget, particularly its
"--timestamping" ("-N") option.

http://www.gnu.org/software/wget/wget.html

(This wheel has already been invented.)
James R. Ferguson
Acclaimed Contributor
Solution

Re: Download files to local server using ftp script based on date.

Hi Gopi:

You need to look at the manpages for 'ftp(1)'. Therein you will find two options that will assist you:

# modtime remote-file

...which shows the last modification time of remote-file

# newer file-name

...which gets the file only if the modification time of the remote file is more recent that the file on the current system

Regards!

...JRF...
Steven Schweda
Honored Contributor

Re: Download files to local server using ftp script based on date.

> [...] two options that will assist you:

That depends a bit on the FTP server. One
possible outcome, for example:

ftp> modtime robots.txt
502 MDTM is unimplemented.

But you could get lucky. With my weak
psychic powers, I wouldn't try to guess the
capabilities of "ftp server" "at their end"
without more (that is, some) actual
information.
Gopi Kishore m
Occasional Advisor

Re: Download files to local server using ftp script based on date.

ThankQ JRF... It solved my problem.. :-)

when I am trying to use modtime for directories, I am getting the error
"550 Could not get file modification time."

Is there any way to use for folders as well??

James R. Ferguson
Acclaimed Contributor

Re: Download files to local server using ftp script based on date.

Hi (again):

> when I am trying to use modtime for directories, I am getting the error "550 Could not get file modification time." Is there any way to use for folders as well??

I don't think so. You could use something like 'dir' to collect a listing (with dates) of the files in a directory and then parse that list, though.

Regards!

...JRF...