ReturnCode Checking for FTP
N. Raghavendra
raghu at mri.ernet.in
Thu May 7 06:41:48 UTC 2009
At 2009-05-06T11:44:46-04:00, Eddie Chen wrote:
> Reading the ftp commands seems to be better, because it will exit(rc)
> if any of "put" or "rename" failed.
Perhaps you've already looked at `lftp', http://lftp.yar.ru/
Exit codes of its commands can be used from the shell, e.g., as
follows:
% set SERVER="ftp://ftp.freebsd.org/pub/FreeBSD/"
% lftp -c "open -e 'cat README.TXT' ${SERVER}" > /dev/null && echo "OK"
OK
% lftp -c "open -e 'cat NOEXIST' ${SERVER}" || echo "FAILED"
FAILED
Further, lftp commands themselves can use the exit codes of previous
commands:
% lftp -c "open -e 'ls foo && ls misc' ${SERVER}"
ls: Access failed: 404 Not Found (foo)
% lftp -c "open -e 'ls foo || ls misc' ${SERVER}"
ls: Access failed: 404 Not Found (foo)
drwxr-xr-x -- ~
drwxr-xr-x -- ~/pub
drwxr-xr-x -- ..
drwxr-xr-x -- .
drwxr-xr-x - 2007-11-02 00:00 fbsd-compat
-rw-r--r-- 1k 2002-04-03 00:00 supfile
HTH,
Raghavendra.
--
N. Raghavendra <raghu at mri.ernet.in> | http://www.retrotexts.net/
Harish-Chandra Research Institute | http://www.mri.ernet.in/
See message headers for contact and OpenPGP information.
More information about the freebsd-questions
mailing list