Rather than going through the trouble of writing programs using third party utilities to ftp (file transfer protocol) files, the below simple shell script will do the job.
ls -t /home/temp/abc*.txt | head -1
The above linux command is to get the most recent file. You can change the file pattern to anything you like.
TEMPFILE01
This is the destination file that will be created.
#!/bin/sh
HOST=myserver.test.com
USER=username1
PASSWD=password1
SRC_FILE="$(ls -t /home/temp/abc*.txt | head -1)"
FILE=TEMPFILE01
echo $SRC_FILE
ftp -nu $HOST <user $USER $PASSWD
put $SRC_FILE $FILE
quit
exit 0
End-Of-Session
ls -t /home/temp/abc*.txt | head -1
The above linux command is to get the most recent file. You can change the file pattern to anything you like.
TEMPFILE01
This is the destination file that will be created.
#!/bin/sh
HOST=myserver.test.com
USER=username1
PASSWD=password1
SRC_FILE="$(ls -t /home/temp/abc*.txt | head -1)"
FILE=TEMPFILE01
echo $SRC_FILE
ftp -nu $HOST <
put $SRC_FILE $FILE
quit
exit 0
End-Of-Session
No comments:
Post a Comment