ftp - How to download files which created today?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ftp - How to download files which created today?
# 1  
Old 06-08-2010
Data ftp - How to download files which created today?

Hello experts,

I have written following script to download files which created today.

Unfortunately, it's not working.

test.ksh:
Code:
#Defining variables
USR='xxx'
PASSWD='yyyy'
HT='test.test.com'
FILE='S*.pdf'
XFILE=$(echo find . -type f -mtime 0)
ZFILE=$(echo ls -tR|grep 'Jun  8')
DIRNAME='/output_files/2010'

#Connecting to ftp site and downloading the file
ftp -n -i -v $HT <<END_SCRIPT
quote USER $USR
quote PASS $PASSWD
cd $DIRNAME
pwd
mget $ZFILE  
bye
END_SCRIPT
ls -l

I also tried:
Code:
mget $XFILE

It transfers all files.

I like to download only those files which created today.

Any suggention/code would be grealy appreciated.

Thanks in advance!!
Dip

Last edited by Scott; 06-08-2010 at 04:56 PM.. Reason: Please use code tags
# 2  
Old 06-08-2010
I am not sure '-mtime 0' will give you what you want. I found some code on the Internet to get today's file and tested it on my machine:

Code:
touch -t `date +%m%d0000` testfile
find . -type f -newer testfile

Make sure you test the code to see you are getting the file names in XFILE before you try the 'ftp' stuff.

Thanks.
# 3  
Old 06-08-2010
take a look to my suggestion to find files that are not older then 1 day:

Code:
find / -type f -mtime -1

hope that help
# 4  
Old 06-08-2010
Thanks guys for helping me.

I tried research3's suggetions:

PHP Code:
find / -type f -mtime -
Above statement also returns y'days files.

soleil4716:
Could you pl. write me what is 'testfile'? How to test?

PHP Code:
touch -`date +%m%d0000testfile
find 
. -type f -newer testfile 
One thing I like to mention that I am trying to download files from remote FTP server.
One of mine friend said this is only possible with 2 FTP sessions.

Thanks

Dip

Last edited by dipeshvshah; 06-08-2010 at 04:11 PM..
# 5  
Old 06-08-2010
But from my point of view you don't have any find command in your ftp environment, therefore you have to create a list locally then grep and get your files.

exp.

Last edited by research3; 06-08-2010 at 04:17 PM..
# 6  
Old 06-08-2010
I am not expert in scripting. Could you pl. send me some code to do that?

Thanks
Dip
# 7  
Old 06-08-2010
give me only 15 min
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ftp get files created in last 30 minutes

Is it possible in an ftp script to get remote files based on whether they have been created in the last 30 minutes? (5 Replies)
Discussion started by: gefa
5 Replies

2. Shell Programming and Scripting

Curl ftp ssl download files

Hello all, I have been struggling with this issue on and off for a couple of weeks now and I just got it all working, so I wanted to share my findings in case some other poor soul needs to know how. First some background on what I'm doing. I am uploading files to different directories based on... (0 Replies)
Discussion started by: msjkadams
0 Replies

3. Shell Programming and Scripting

Download files every one second using ftp script

Our main Server "Srv1" is used to generate text files based on specified criteria and it is also connected to two clients (pc1 and pc2) which are responsible for getting the files from Srv1 as it follows: 1. pc1 ( which represents my UNIX machine ) uses shell script to copy the files from Srv1 2.... (3 Replies)
Discussion started by: arm
3 Replies

4. Linux

List all files created today exclude last one

Hi, ALL thanks in advance, i listed all files using this command ls -ltr $(date +%Y%m%d)*.xmlbut i would like to exclude the last one created ; Best regard MEROUAN Use code tags, thanks. (4 Replies)
Discussion started by: merouan
4 Replies

5. Shell Programming and Scripting

How to find files created today in a particular directory?

Dear All, I want a Hp Ux command to find out the files created today in a particular directory or mountpoint. Kindly help. Thanks Bhaskar (10 Replies)
Discussion started by: sudiptabhaskar
10 Replies

6. Shell Programming and Scripting

Calculate Files Created Today

I need to figure out how to get all the files from a certian dir ./123/*sat files and ./230/*sat files and several other directories which have these *sat files in them. I need to calculate how many were created today and how many yesterday from 2:00 pm on the 28th to 2pm on the 29th. It's a... (1 Reply)
Discussion started by: xgringo
1 Replies

7. Shell Programming and Scripting

Download previous day files through FTP

Hi All, I have a scenario where I need to download the previous day modified files from other server to my server through FTP . Could any one please send me the shell script for the same. I used the following but I dont know how to proceed after this. ftp -n -i -v $IP <<ENDOFinPUT >>... (3 Replies)
Discussion started by: sarathchandrach
3 Replies

8. Shell Programming and Scripting

Files with 0 file size and created today

hi, I am building a script to identify those files created/modified today and with file size 0. I am able to find the files with 0 file size and created/modified in last 24 hrs as shown below but not today (current date), I tried using (touch -t time filenm) but in my version of unix at work it... (7 Replies)
Discussion started by: rushs682
7 Replies

9. Shell Programming and Scripting

script for download files from ftp site

I'm new to scripting. I'm trying to write a script to download files from ftp site, the following is the script and the message i get after running the script. no files were downloaded :( Thanks advance! script: #!/usr/bin/ksh DAY=`date --date="-1 days" +%y%m%d` ftp -v -n "ftp.address" <<... (5 Replies)
Discussion started by: tiff-matt
5 Replies

10. UNIX for Dummies Questions & Answers

To list all the files created today with directory path

Hi, Can any one tell the command to list all the files that are created as of today from all the directories? The Command "ls -ltR" is listing all the files. But I want the list of files that has been created as of today along with the directory path:) Thank you in advance.:) Regards,... (4 Replies)
Discussion started by: meetusha.b
4 Replies
Login or Register to Ask a Question