#! / bin / ksh. /tbill/app/.profile
SQLPlus err / err123 @ Billing @ / tbill / data / recyclepath / tmp / ftp_file_data.sql
OnNInit () {UserHome = $ Home if [-f "/tbill/data/recyclepath/tmp/autoftp.conf"]; Then. /TBILL/Data/recyclePath/tmp/autoftp.conf echo machine $ host> $ userhome / .NETRC Echo login $ user >> $ userhome / .netrc echo password $ passwd >> $ userhome / .netrc
CHMOD 600 $ usrHome / .Netrc Echo ====================================== c "host = $ host" echo "user = $ user "Echo" password = x "echo" Remote Dir = $ RemoteDir "echo" Source Dir = $ sourcedir "echo" Success Dir = $ backupdir "echo" pattern = $ pattern "
echo ============================== ======= Return 0 else return 1 fi
}
showinfo () {echo NAME echo "autoftp -automatic upload file to ftp server" echo SYNOPSIS echo "autoftp"} checkdir () {if [-d $ sourceDir!];! then echo "ERROR source dir $ sourceDir is not found! "Return 1 Fi if [! -D $ backupdir]; THEN MKDIR $ backupdir fi return 0} Putfiles () {ftp -i $ host << EOFCD $ RemoteDirmput $ @ Byeeof} ########### ## Main procedure ########################## = v "]; then showinfo eXitfi # ============================================= ============ # backup .NETRC fileif [-f ~ / .Netrc]; Then MV ~ / .NETRC ~ / .NETRC.OLDFI # =========== ========================================================= □itif [$? -ne 0 ]; The echo "error! Autoftp.conf not exist! please prepare it" exit 1fi
Checkdirif [$? -ne 0]; The EXIT 1FI # begin ftpdateecho "Begin FTP" CD $ SOURCEDIR
While read file; do if [-f $ sourcedir $ file]; the Touch "$ file.chk" MV $ file "$ file.txt" putfiles "$ file.txt $ file.chk" mv $ file.txt / tbill / DATA / RECLEPATH / TMP / $ BACKUPDIR RM $ file.chk echo "PUT $ file.txt $ file.chk done!" Fi Done <
Dateecho "ftp end"