Re: Get the most recent file in a remote server using FTP script



anujairaj a écrit :
Hi,
I have a few files with a timestamp appended in the end ,in a remote
server,I need to get the most recent one in the ftp scripot.But Iam
unable to do it using :


MOST_RECENT_FILE1=`ls -1t ${FTP_OUTPUT_DIR}${FTP_OUTPUT_FILE1}* | head
-1 `
get ${MOST_RECENT_FILE1} ${FTP_INPUT_DIR}${FTP_INPUT_FILE1}.csv

it says,file not found.
Can anyone help me on this?
thanks


Hi,

this cant work, the output of the command ls -lt * | head -1 would
consist of a line such as the following :

-rwxr-xr-x 1 user group 748 2006-09-23 12:57 mostRecentFile

To catch the filepath(relative to the rep you are in), you need to pipe
the previous output to obtain something like : ls -lt * | head -1 | awk
'{print $NF}'

I guess you could play with the echo command in your ftp script to see
if the result is relevant to you.

Hope this help.:)
.