How to find the status of FTP operation inside shell script
Posted on 2006-06-27
My Shell Script looks like this .
# Copying the dat file to Pool Talk server
ftp -n $EPT_SERVER_NAME <<!
quote user $EPT_USER
quote pass $EPT_PASSWORD
# Copying the dat file to BloomBerg server
ftp -n $BBERG_SERVER_NAME <<!
quote user $BBERG_USER
quote pass $BBERG_PASSWORD
As it is obvious from the above code, that i am trying to ftp file to two different servers. Now i have a new requirement that says that if ftp to the first server succeeds, then i don't have to ftp the file to the next server. To achive that i need to know the status of the ftp operation. Please let me know how to find the status of the ftp operation inside shell script.
I tried $?, which i heard will give me the status of the last shell command. but in this case , i get 0 all the time even if the ftp fails to succeed. Please let me know the other solutions.