current day remote files from FTP


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers current day remote files from FTP
# 1  
Old 04-11-2012
current day remote files from FTP

Hi All,

I have to work on a korn shell script to pick up only the current day files dropped on the remote server (using ftp).
The file do not have daytimestamp on it. It has to be based on server time (AIX)

The file naming convention is "test_file.txt"

When I log in into the ftp account from browser I can see the day the file dropped.

However when I log in from the server using ftp commands manually, I can't find the day the file arrived.

Can somoene please help me with the script.

Thanks & Regards
pavan
# 2  
Old 04-11-2012
After issuing a suitable ftp cd command. Please post a small sample from the ftp command dir command. Preferably include a sample where the date is a single digit day.
This should show posters the format on your system.
# 3  
Old 04-11-2012
current day remote files from FTP

Code:
ftp -inv $ftp_host
$user
$password
cd $ftp_dir
ls test_file.txt
ls_test_file.txt
get test_file.txt
bye

however I don't know from above when the file was dropped on the server. I have to pick up only if the file was dropped today.

Thanks
Pavan

Last edited by methyl; 04-11-2012 at 05:41 PM.. Reason: please use code tags
# 4  
Old 04-11-2012
Please reply to my post #2.

You cannot do the entire process with only FTP.
This is going to end up as a multi-stage process:
1) FTP: Get a directory listing from the remote directory
2) Shell: Process the directory listing to find today's files
3) FTP: Get only the file(s) identified above


Btw. The conventional design of this sort of process is to rename the files after successful transfer so it is easy to identify new files.
# 5  
Old 04-11-2012
current day remote files from FTP

This is a new process I am trying to put in place. since we pick up files from external remote server, I don't have rename privileges (or the user ID that I am using.) They give us read only previleges.

can you please tell me how do I achieve this,

FTP: Get a directory listing from the remote directory

Thanks
Pavan
# 6  
Old 04-11-2012
1) log in with ftp
2) ls
# 7  
Old 04-11-2012
current day remote files from FTP

I ran the following FTP commands manually (on AIX server )

Code:
ftp -inv $ftp_host
$user
$password
cd $ftp_dir
ls test_file.txt
ls_test_file.txt
get test_file.txt
bye

when i do ls <filename>

it just list the file but it will not give me complete listing such as

Code:
-rwxr-xr-x    1 <user>   <usr>            4746 Apr 11 12:13 test_file.txt

how do I get this complete listing,

Thanks
Pavan

Last edited by methyl; 04-11-2012 at 05:42 PM.. Reason: code tags
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Error when connecting to remote server to find files with timestamp today's day

I am connecting to remote server and try to check if files with timestamp as Today's day are on the directory. Below is my code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly; Today=`date +%Y%m%d`; if ;then echo "We... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. UNIX for Dummies Questions & Answers

How to save current day files only?

i want to save current day file daily for this is am using below command. cp -p $(ls -lrt | grep "Apr 15" | awk '{print $9}' in order to script this part, i am saving date output in a file using below command date | awk '{print $2,$3}' >>t1 thru below command i want to list the file of... (7 Replies)
Discussion started by: scriptor
7 Replies

3. UNIX for Dummies Questions & Answers

Remote FTP Backup -Tar archive+ encrypt+ split to a remote ftp

I have a huge directoy(200+ gb) for backup. I want upload the tar file(split files) simultaneous to a remote ftp. (pipeline, stdout, stdin etc.) I don't want write a data to local hdd. I have a ssd hdd. thanks. this code doesn't work.( yes i know the problem is split command!) tar cvzf -... (8 Replies)
Discussion started by: tara123
8 Replies

4. UNIX for Dummies Questions & Answers

Move the files between Current day & a previous day

Hi All, I have a requirement where I need to first capture the current day & move all the files from a particular directory based on a previous day. i.e move all the files from one directory to another based on current day & a previous day. Here is what I am trying, but it gives me errors.... (2 Replies)
Discussion started by: dsfreddie
2 Replies

5. Shell Programming and Scripting

Command to list current day files only

Hi All, can anyone pls share the command to list the files of current day only. i want to check if there are any files in a particular directory which are not of current date. (6 Replies)
Discussion started by: josephroyal
6 Replies

6. UNIX for Dummies Questions & Answers

Can I copy files on remote server with ftp ?

I just realize the only way is to download and upload again.. is not possible to copy them remotely with the ftp protocol ? thanks (2 Replies)
Discussion started by: aneuryzma
2 Replies

7. Shell Programming and Scripting

Problem in Downloading one day old files from FTP site

HI, I'm downloading one day old files from ftp site. Below is my script ---------------------------- printf "open $HOST \n" > ftp.cmd printf "user $USER $PASSWD\n" >> ftp.cmd printf "bin\n" >> ftp.cmd #printf "cd /Models/\n" >> ftp.cmd printf "prompt\n" >> ftp.cmd printf "for oldfile... (4 Replies)
Discussion started by: shekhar_v4
4 Replies

8. 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

9. Shell Programming and Scripting

delete files one day old in current month only

i want to delete files that are one day old condition is files should be of current month only ie if iam running script on 1 march it should not delete files of 28 feb(29 if leap year :-)} any modifications to find $DIR -type f -atime +1 -exec rm -f{}\; (4 Replies)
Discussion started by: maverick
4 Replies

10. Shell Programming and Scripting

How to compare prev day file to current day file

Hi all: I am new to this board and UNIX programming so please forgive if I don't explain something correctly. I am trying to write a script to keep track of our links, we link one program written for Client A to Client B's directory. What we want to do is to keep track of our linked programs... (1 Reply)
Discussion started by: Smurtzy
1 Replies
Login or Register to Ask a Question