LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-06-2011, 03:29 PM   #1
igsunny
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Rep: Reputation: Disabled
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
 
Old 09-06-2011, 04:09 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
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.
 
Old 09-06-2011, 04:14 PM   #3
igsunny
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Unhappy 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
 
Old 09-06-2011, 04:27 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,120

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
is it possible to just use scp with keys or are you married to ftp ?
 
Old 09-06-2011, 04:31 PM   #5
igsunny
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Red face How to exit from automated FTP process on failure

I can not use anything but FTP
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to wait for the process and know if the exit code of the sub process williamhomanchun Linux - General 10 08-11-2008 01:32 PM
scheduler invocation, process selected, process entry and exit linuxdoniv Programming 1 03-14-2008 08:37 AM
scheduler invocation, process selected, process entry and exit linuxdoniv Programming 1 03-14-2008 03:48 AM


All times are GMT -5. The time now is 06:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration