Tim Holloway wrote:Rather than a straight shell script to do the upload, you might want to look at "expect" and see if it will work for you. It's designed for that sort of task. You'll probably have to get samples of both "upload succeeded" and "upload failed" messages from that particular server so that you'll known what to, er, expect.
You CAN terminate the ftp client program in between file uploads, but there's a fair amount of overhead/delay each time you disconnect and reconnect, so I'd try and do it all in one go, myself.
In the event of switching from one FTP host to another, the overhead is going to be there regardless, so whether you run the FTP client twice or simply once with a disconnect from the first host followed by a connect to the second is mostly a matter of taste. Running each connection on a separate instance of the client program does, however mean that you can fork them and run the two sessions concurrently instead of having the second connection wait on the first one.
Thank you for letting me know about "expect."
I have another question. Here is a portion of my script. When the script below executes, I'm getting a message saying that I'm already logged in. $HOST1 and $HOST2 are different URLs. How can I avoid this error?
ftp -inv $HOST1 <<EOF
quote USER $USER
quote PASS $PASSWD
cd $DIR
ftp -inv $HOST2
quote USER $USER
quote PASS $PASSWD
cd $DIR
bye
EOF
If I were to execute the following script, the script only allows me to log on to the $HOST1, but not $HOST2. Any reason why?
ftp -inv $HOST1 ><<EOF
quote USER $USER
quote PASS $PASSWD
cd $DIR
bye
ftp -inv $HOST2
quote USER $USER
quote PASS $PASSWD
cd $DIR
bye
EOF