Unix script to FTP file . Also can be used in Datastage job.

#!/bin/ksh
# ****************************************************************
# ***   FTP FILE
# *******************************************************************************
# ***   This script will transfer file from one location to other location
# ***   This script should be typically used as a after-job script.
# ***   However, it can also be used as an before-job script.
# ****************************************************************


        hostName=$1      # target server name.
        usrName=$2      # target server login user name.
        usrPwd=$3     # target server login password.
        ftpPath=$4      # Location directory path.
        fileName=$5    # Ftp file name
     
     
        # ================= Run FTP command ===================

         echo "Attempting to connect to the HOST SERVER "
         ftp -n -v -q $hostName <<END_SCRIPT
         echo "Submitting Username"
 quote USER $usrName
         echo "Submitting  Password"
 quote PASS $usrPwd
         echo "Changing the path to required directory"
         cd $ftpPath
         echo "Transfering the file to required directory"
         put $fileName     # ***   you can change to get as per the requirements
         echo "Quiting Ftp script"
         bye
         END_SCRIPT            
         exit

 

No comments:

Post a Comment