Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I check result of FTP in shell script

Status
Not open for further replies.

another

IS-IT--Management
Nov 14, 2001
1
US
I have written a bash shell script that
uses FTP to get some files from a remote machine.
Is it possible to check result of each command in some way?
I there's an login failure or if the file transfer/connection is interupted I want to write that error information to a file.

The FTP part looks like this;

ftp -n -i <<-EXIT

open $REMOTE_HOST
user $REMOTE_USER $REMOTE_PASSWORD
cd $REMOTE_DIR
mget *.rdy
bye
EXIT

Any suggestions on this?
 
Change this line of your script:

ftp -n -i <<-EXIT

to look like

ftp -n -i >/tmp/ftp.output 2>&1 <<-EXIT

and that will put all of the output from the ftp command into the file /tmp/ftp.output - you can then use the grep command to search for errors Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top