Script to Coping files to FTP server

This is a script to upload very recent file to ftp sever

Examples..

Folder 1 contains 5 file like

File name date and time
1.txt 27-07-2011 16:45
2.txt 27-07-2011 16:30
3.txt 26-07-2011 17:30
4.txt 25-07-2011 13:30
5.txt 24-07-2011 12:00

in this folder I need to upload file latest file i.e.,

“1.txt 27-07-2011 16:45”

please follow the script to upload the file

script


!/bin/bash

#

ftp script

#

Change to folder which contains file to be upload

cd /path-to-folder/folder1

Copy the latest file to folder2

cp $(ls -1t *.txt | head -1) /path-to-folder/folder2

Change to folder which contains latest file to be upload

cd /path-to-folder/folder2

Using WPUT command to upload the contains of folder to FTP server

wput ftp://username:password@server-ip/ .

Emptying the folder after the upload

rm -r *

################################################################################################

Its is a shell script you can use it on any linux platform

Note : If you not having wput command in linux please download and then run the script.
wput rpm download link

ftp://ftp.univie.ac.at/systems/linux/dag/fedora/8/en/i386/RPMS.dries/wput-0.6.1-1.fc8.rf.i386.rpm

You can use the same script in windows too, their you need to install cygwin application for linux interface.