[HPADM] SUMMARYII: FTP return codes

From: Quinn, Bryan (Bryan.Quinn@CooperTools.com)
Date: Tue Dec 10 2002 - 08:07:15 EST


I thought I would add this response from Bill Hassell, to my previous
summary.

Just a clarification: ftp does not change the
return code based on whether a file was transferred
successfully or not. ftp is an interactive command
system and *every* command has the potential to
fail (like cd or dir as well as get or put) so it
is impossible to reflect the success or failure of
an ftp session with one return code. I believe
that the only time the return code will be non-zero
is when the address/hostname is invalid. (Try it)

You'll need to validate the successful transfer
using a better method, perhaps using the sum
command on the source and destination and sending
the result using email or reverse ftp in a separate
session to see if the sums are the same.

--
Best regards,
Bill Hassell, pooderbill@mindspring.com
Thanks to all who responded!
-Bryan
> Thanks to everyone who responded!
> 
> I used the basic structure that Neeraj Lal provided and modified to fit my
> situation a little better. Below is the syntax that I used and below that
> is Neeraj's response. At the very bottom is my original post.
> 
> My Syntax:
> 
> ftp -n -v < $tmp_file > $err 2>&1
> 
> grep 'Transfer complete.' $err > /dev/null
> 
> if [ $? -eq 0 ]
> then
>        some command
> else
>        some other command
> fi
> 
> 
> Neeraj's Suggestion: 
> 
> cat $DATA_DIR/scriptx.ftp | ftp -v -n > $DATA_DIR/ftp.err
> 
> grep 'Transfer completed successfully.' $DATA_DIR/ftp.err > /dev/null
> 
> if [ $? -eq 0 ]
> do something
> else 
> report error
> fi
> 
> 
> 
> My Original Post:
> Hello Admins,
> 
> Got a question as usual. I am in the process of writing a script that will
> monitor an ftp from our UNIX box to a Windows box. I have tried checking
> using the following if statement, which seems to be something is used
> quite
> regularly in scripts, but this does not seem to work if you have an error.
> 
> status=$?
> 
> if [ $status != "0" ]
> then
>     do something
> else
>     do something else
> fi
> 
> Does anyone have any thing else I can try.
> 
> Thanks!
> Bryan Douglas Quinn
> UNIX Support Specialist
> Cooper Power Tools
> Lexington, SC
> (803) 808-6770
> Bryan.Quinn@coopertools.com
> 
> 
> 
> --
>              ---> Please post QUESTIONS and SUMMARIES only!! <---
>         To subscribe/unsubscribe to this list, contact
> majordomo@dutchworks.nl
>        Name: hpux-admin@dutchworks.nl     Owner:
> owner-hpux-admin@dutchworks.nl
>  
>  Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse
> only)
>             http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse &
> search)
--
             ---> Please post QUESTIONS and SUMMARIES only!! <---
        To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl
       Name: hpux-admin@dutchworks.nl     Owner: owner-hpux-admin@dutchworks.nl
 
 Archives:  ftp.dutchworks.nl:/pub/digests/hpux-admin       (FTP, browse only)
            http://www.dutchworks.nl/htbin/hpsysadmin   (Web, browse & search)


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:23 EDT