Sunday, June 16, 2013

Script to perform FTP in background


Usually to transfer files from Fix Central to the servers, while downloading to your server it takes lot of time, so during this period we should make sure your network not to disconnect.

To avoid this problem, we can use a script to run this file transfer in background so that, there will be no need for us to be attentive towards the ftp transfer.


Here is the scripttttt




#!/bin/sh
USERNAME="anonymous"
PASSWORD="anonymous"
SERVER="FTP SITE SERVER NAME"
 
# local directory to pickup *.tar.gz file
FILE="/ecc/hsb/H60987058"
 

# login to remote server
ftp -n -i $SERVER <<EOF
user $USERNAME $PASSWORD
cd $FILE
mget *.*
quit
EOF


- Just put these entries in a file and can be executed as below in background.

Save the content to the file  --> auto-ftp.ksh
Command :   nohup auto-ftp.ksh > /tmp/ftp.out &

- Note: The command has to be executed in a directory where you need to place the download the files!!!




2 comments:

  1. Thank you for this post,this really did help in letting me go home early, rather struck in office for hours to get it complete

    ReplyDelete