FTP file upload is not a big task. It is easy to upload file from command line as well as using free X window based FTP clients such gFTP. However, it is often required to automate FTP file upload task using some kind of scripts such as bash. Below is the subroutine in bash that I often use to upload log files to FTP server.
---------------------------------Start----------------------------------->
###Accepts following arguments
### 1. FILE TO UPLOAD
### 2. HOSTNAME TO FTP
### 3. USER NAME
### 4. USER PASSWORD
###
uploadLogs(){
FILETOUPLOAD=$1
HOSTNAME="$2"
USERNAME="$3"
PASSWORD="$4"
ftp -dvin $HOSTNAME <<EOF
quote USER $USERNAME
quote PASS $PASSWORD
mkdir $PLATFORM
cd $PLATFORM
binary
hash
put $FILETOUPLOAD
quit
EOF
}
<--------------------------------End------------------------------------
Bash subroutine above is almost self explanatory. Do you use any other mechanism to automate FTP session or FTP file upload task? If yes then let everyone know in comments below.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=8e7fff05-d69e-47a0-91cd-3c2748ea796e)


1 comments:
Your valuable comments are welcome. (Comments will be moderated.)