DanSandbergUCONN <daniel.sandb...@uconn.edu> wrote: > Hi All - If I want to write a script that uses ftp to transfer a file and > then, only after the file has been successfully transferred, I do something > else - how do I tell my script to wait until the ftp is finished before > doing the next command? Is that even possible?
Waiting for the command to finish is what the shell normally does. If a command is followed by "&", then you get the other behavior - the command is started, and then the shell immediately continues with the next command. Without "&", the shell waits for the command to finish before proceeding. To test that the command was successful, there are a few different choices. You could use "set -e", as long as your script uses simple enough syntax. But there are enough tricky situations that get in the way of "set -e" that I never use it. You could put "&&" after every command, to ensure that the script will stop at the first command that fails. That's what I generally do. Or, if the ftp command is the only one whose success you care about, you could use "if": ... if ftp_command; then echo the transfer was successful else exit fi ... paul