FTP error codes
am 13.12.2006 15:16:51 von dennishancy
I have a Unix shell script which includes a call to FTP.
The code immediately following the call to FTP currently looks like
this:
if [ $? != 0 ]; then
echo "FTP script failed. Exiting with error."
exit 2
fi
However, I've been asked to modify this so that if the file isn't
there, we do not want to exit with an error code.
I suspect that the FTP script can fail for a variety of reasons - one
of which is that the file isn't there.
Is there one particular error code that specifically means "the file
isn't there"? Better yet, is there a list of all available error codes
for FTP? Thanks.
Dennis Hancy
Eaton Corporation
Cleveland, OH
Re: FTP error codes
am 13.12.2006 16:45:53 von OldSchool
dennishancy@eaton.com wrote:
> I have a Unix shell script which includes a call to FTP.
>
> The code immediately following the call to FTP currently looks like
> this:
>
> if [ $? != 0 ]; then
> echo "FTP script failed. Exiting with error."
> exit 2
> fi
>
> However, I've been asked to modify this so that if the file isn't
> there, we do not want to exit with an error code.
>
> I suspect that the FTP script can fail for a variety of reasons - one
> of which is that the file isn't there.
>
> Is there one particular error code that specifically means "the file
> isn't there"? Better yet, is there a list of all available error codes
> for FTP? Thanks.
>
>
>
> Dennis Hancy
> Eaton Corporation
> Cleveland, OH
Ok, first off, the script snippet should never return an error, it will
only indicate if the ftp command worked or not.
for the ftpd error / success codes, check either "man ftpd" or
http://falcon.jmu.edu/cgi-bin/man-cgi?ftpd
in order to determine success/failure of the ftp session, you will need
to log the output of the session to a file and then examine the files
contents. Something along these lines:
ftp someserver > ftpdump.txt <
get somefile
by
EOF
lcount=`grep 250 ftpdump.txt | wc -l`
mcount=`grep 550 ftpdump.txt | wc -l'
..
..
..
then if lcount is 0 and mcount is 1, the transfer failed due to missing
file. if lcount is 0 and mcount is 0, you had other issues