Hi guys,
I'm wrinting a dropbox script for my client. I'm supposed to conenct to their server and get files everyday for processing and then delete the file off the server. The problem i face now is that the connection is not very stable.
To work around this I want to be able to build error checking into my script so that if the connection fails the script will run again and try to recconect. And also based on the exit status i will be able to know if i can delete the files off the server.
My ques is, how do I check the exit status for the script below. I'm open to the idea of using a different client like ncftp if required.
This if the connection method used by the client's side.
Code:
ftp -niv ftp.example.com
user user1 [prompts for password]
user anonymous@ftp.example.com
user user1 [prompts for password]
This is is the script i've written.
Code:
# Ftp
hostname="ftp.example.com"
username1="ftpuser"
username2="anonymous@ftp.example.com"
password1="xxxxxxx"
password2="example@example.com"
echo
echo ----------------------------------------------------------
echo Ftp script started at `date`
echo ----------------------------------------------------------
echo
echo
echo ----------------------------------------------------------
echo STAGE 1 - Getting files from client
echo ----------------------------------------------------------
echo
cd $INBOX
ftp -inv $hostname << EOF
quote USER $username1
quote PASS $password1
quote USER $username2
quote PASS $password2
quote USER $username1
quote PASS $password1
passive
cd outgoing
pwd
type binary
mget *
bye
EOF