bashftp

Sleep in an ftp bash session


I am launching an FTP session automatically, with

ftp -inv globe.forward.my_machine <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd petitions
ls
put my_petition.txt
sleep 10
cd ../data
get my.tar
quit
END_SCRIPT

It almost always works, but when it doesn't I have the suspicion that it could be due to some time lag launching the petition and receiving an answer. So, I introduced an sleep command to ensure the files are available, but I obtain "?Invalid command". How can I force an sleep in an ftp session in bash?


Solution

  • There's no sleep command in ftp.

    An easy solution is to execute the sleep in a shell. Use ! to escape to the shell temporarily:

    !sleep 10
    

    See ftp man page.

    A related question: In a shell script, how to suspend and resume FTP session without losing connection?