LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to exit from automated FTP process on failure (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-exit-from-automated-ftp-process-on-failure-901475/)

igsunny 09-06-2011 04:29 PM

How to exit from automated FTP process on failure
 
Hi Everybody,

I have the following script. It set as a cron job. It works fine if the file is present on the server, but if it is not, the script hangs.
How can I trap the failure and then exit from the script?

#! /bin/bash
# Get the new pgp files...
sftp username@ftp4.server.com <<EOF
cd abc/ToScripNet
get abc*.txt.pgp
rm abc*.txt.pgp
!EOF

exit

colucix 09-06-2011 05:09 PM

The exclamation mark before the closing EOF is not needed (it results in a command not found error). Try to remove it and add a quit statement to gracefully close the sftp session.

igsunny 09-06-2011 05:14 PM

How to exit from automated FTP process on failure
 
Unfortunately, I am still having the same problem:

Couldn't delete file: No such file or directory

schneidz 09-06-2011 05:27 PM

is it possible to just use scp with keys or are you married to ftp ?

igsunny 09-06-2011 05:31 PM

How to exit from automated FTP process on failure
 
I can not use anything but FTP


All times are GMT -5. The time now is 06:57 AM.