I wrote a small shell script to automate an ftp transfer as follows:
#!/bin/sh
echo "user anonymous
[email protected]
bin
cd somedirectory
get somefile
bye" | ftp -n ftp.somewhere.com
Works pretty well by scheduling with an at job.
However, I've been attempting to add re-try capabilities to the script with limited success. Here's the new script:
#!/bin/sh
set loopcount = 0
while ($loopcount < 20)
set loopcount = `expr $loopcount + 1`
echo "user anonymous
[email protected]
bin
cd somedirectory
newer somefile
bye" | ftp -n ftp.somewhere.com
sleep 600
end
Here I use the newer command to ensure that if I do get connected again, I don't restart the transfer. Also the sleep command is used to give a 10min break between attempts.
However, I just get a complaint that there's mismatched "." I guess I need to get all the echo stuff on one line, but can't seem to find the correct newline character to put in. (I've tried $'\r' but it doesn't like that). What I really want is "ftp -n somewhere.com -retry 20" but there's no such function...
Can anyone help ?
moog
------------------
No Norm, those are your safety glasses... I'll wear my own thanks.




Reply With Quote