[SunHELP] How to trap ftp error codes

Naser Ali Ali.Naser at irs.gov
Thu Jul 24 14:09:14 CDT 2003


Thanks.

-----Original Message-----
From: adh at an.bradford.ma.us [mailto:adh at an.bradford.ma.us]
Sent: Thursday, July 24, 2003 2:23 PM
To: sunhelp at sunhelp.org
Subject: Re: [SunHELP] How to trap ftp error codes


"From: Naser Ali <Ali.Naser at irs.gov>
"
"I am trying to trap ftp return code or error code to make my automated ftp
"script more robust. Is there a way to accomplish this.
"
"Any pointers will be great help.

in ksh, $? is always the exit value of the last command executed.  so
you could do something like

#!/usr/bin/ksh -p

ftp <target> <<-EOFTP
.
.
.
.
bye
EOFTP

if (( $? ))
then	# nonzero, ftp failed
	print -u2 "\n${0##*/}: warning!  ftp failed!\nreturn code was
$?\nerror number was $ERRNO\n"
else	# zero, ftp succeded
	print "hooray!  all done."
fi

btw, ksh supports $ERRNO, if that has any value.

you might also want to look into wget and/or curl.
________________________________________________________________________
Andrew Hay                                  the genius nature
internet rambler                            is to see what all have seen
adh at an.bradford.ma.us                       and think what none thought
_______________________________________________
SunHELP maillist  -  SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp



More information about the SunHELP mailing list