* Re: Does ftp define an exit status?
2000-01-03 5:00 Does ftp define an exit status? broeni
@ 2000-01-15 5:00 ` Yong S. Yi
0 siblings, 0 replies; 2+ messages in thread
From: Yong S. Yi @ 2000-01-15 5:00 UTC (permalink / raw)
broeni@my-deja.com wrote:
> Does somebody know if ftp does define an exit status or not?
>
> I've tried the following:
> broeni@rtx5../broeni> ftp -nv myserver <<END
> > user broeni wrong_password
> > bye
> > END
> Connected to 192.168.17.8.
> 220 M01BS0D5 FTP server (Digital UNIX Version 5.60) ready.
> 331 Password required for broeni.
> 530 Login incorrect.
> Login failed.
> 221 Goodbye.
> broeni@rtx5../broeni> echo $?
> 0
>
> Obviously there was an error, but the exit status of ftp is 0.
Look at what you put for the commands: "bye". That told ftp(1) to exit
with 0. Now, had this been a case where 'ftp' detected an error with the
program (not whether the remote server detected an error w/ password,
etc), it may have exited with 1 (or otherwise). Check with the source
code, if you have it.
> Another try with an even more obvious error:
> broeni@rtx5../broeni> ftp -nv not_existent <<END
> > user broeni wrong_pass
> > END
> ftp: Unknown Host not_existent
> Unknown host
> Not connected.
> broeni@rtx5../broeni> echo $?
> 0
>
> Again the exit status does not indicate the failure of the ftp.
> Is something wrong with the ftp version I'm using (operating system:
> OSF1 V4.0 1091 alpha)?
Again, this is somewhat similar. Try doing 'ftp non_existent' (should be
"non-existent", BTW). You'll be dropped back down to the 'ftp> ' prompt.
And a ^D, quit, bye, etc. will get you out. In your example, it doesn't
need to do that since there is no more input and an EOF has been
reached. So it exited normally, again.
It'd exit with 1 if:
1) It can't find the 'ftp' service (i.e., /etc/services)
2) It sees an unknown command line option
3) Can't fork() for a shell command
4) When it calls fatal() (simply a message printed to stderr saying it
encountered an error, and of course exit()'ing)
... AFAIK.
> How can I reliably detect an error during a ftp session?
Not too many ways, other than perhaps modifying 'ftp' (if you have the
sources for it; or simply getting a different, open-source 'ftp', or
other FTP clients like 'ncftp', 'lftp', etc), comparing text strings, or
whatnot.
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Sent via uh... blah http://www.blah.com/
AFTER and only after you buy and get ripped off.
-y.
--
Yong S. Yi KeyID 1024/8B4FF151 http://async.org/~ysyi/
PGP Key Fingerprint = 3A 65 AE 82 07 2A EF 73 0B 84 67 5D 1D 96 9F 8D
<ysyi@alf.dec.com> Enriched, VCard, and HTML messages > /dev/null
^ permalink raw reply [flat|nested] 2+ messages in thread