LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:20 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
Open Source Consulting | Domain Registration