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.
After issuing a suitable ftpcd 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.
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.
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
If it doesn't give you a complete listing, you can try ls -l, but remember, ftp is not a shell. You don't get the real ls command. This simple listing might be all you get.
Please do type the ftpdir command requested in post #2. It is not always the same as ls in ftp (but it might be the same) .
To answer your main question:
Within ftp there is a special syntax for the dir command to output the directory listing to a local file. This is useful to us.
These are ftp commands not Shell commands.
Make sure that your current local directory is suitable to receive the directory listing:
lcd suitable_dir
Then list the files in the directory and output to a file on the local server:
dir * mydirectory.lst
Once we have the directory listing we can find today's files. But, because date formats vary across the planet we need to see the date format.
Corona688 makes a valid point. Are you running ftp or sftp ?
Anyway, first time I have seen a server set for both ftp and sftp .
Ignoring the ftp command ls -l which is not always supported (as you have found), please do type the universal (works with every version of ftp ever) command dir .
Off topic. The ftp command dir predates Microsoft. There is a debate in the What's on your mind Forum about whether to call a Directory a Folder. I rest my case.