Re: capturing a return code



On 2007-11-12, Jim Showalter <jshowalter@xxxxxxxxx> wrote:
I have a conundrum best explained by the following items:

Cut from "man ncftpget":

DIAGNOSTICS
ncftpget returns the following exit values:

0 Success.

-------------------------------=<(*)>=--------------------------------

Snippet from "bak_website" script:

echo "bak_website: Now archiving http://mywebsite.com";
ncftpget -RV -u user -p passwd ftp://mywebsite.com .

# move and list the archived files
val=$?
if [ $val -eq 0 ]; then
mvarc
# moves files from dir n to dir n+1
else
echo "bak_website failed"
fi

-------------------------------=<(*)>=--------------------------------

Message 44:
From droid@xxxxxxxxx Mon Nov 12 04:17:56 2007
X-Original-To: droid
Delivered-To: droid@xxxxxxxxx
From: droid@xxxxxxxxx
To: droid@xxxxxxxxx
Subject: Cron <droid@opus> /usr/local/bin/bak_website
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/droid>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=droid>
X-Cron-Env: <USER=droid>
Date: Mon, 12 Nov 2007 04:00:02 -0500 (EST)

bak_website: Now archiving http://mywebsite.com
ncftpget: server said: File successfully transferred
bak_website failed

-------------------------------=<(*)>=--------------------------------

On inspection I find the file was successfully transferred but mvarc
never executes. Shouldn't the message from the remote server set a
return code of zero? How can I capture ncftpget's return code?

val=$?
echo "return code=$val"

You might try adding the -d option to ncftpget. It could be that one or
more files were transferred successfully but some were not, or the ftp
server is not a Unix server.
.



Relevant Pages

  • capturing a return code
    ... Cut from "man ncftpget": ... Success. ... echo "bak_website: Now archiving http://mywebsite.com"; ...
    (comp.unix.shell)
  • Re: if else
    ... if errorlevel 0 echo %1 successful ... if errorlevel 0 echo %1 successful ==> echo successful when machine ... cusrmgr.exe returns 0 for success, ... if NOT errorlevel 1 else (echo fail) ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: shell scripts and escaped charecters in file names
    ... I am trying to get the following script to run with no success. ... echo $file end ... IFS ) ...
    (freebsd-questions)
  • Rotate the logs
    ... i am posting a long script which will remove logs when it reaches 15 ... #* variable "a" is used to store the size of the stdout.log file ... echo "Success" ...
    (comp.unix.shell)
  • Re: Simple bash script query
    ... This applies only to conditional operators in ... indicating it's success or failure. ... echo $salary1 ... test $salary1 -eq $salary2 ...
    (alt.os.linux.suse)