PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > capturing a return code
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

capturing a return code

Réponse
 
LinkBack Outils de la discussion
Vieux 12/11/2007, 11h39   #1
Jim Showalter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut capturing a return code

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@opus.ynet Mon Nov 12 04:17:56 2007
X-Original-To: droid
Delivered-To: droid@opus.ynet
From: droid@opus.ynet
To: droid@opus.ynet
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?

droid
--
Whom computers would destroy, they must first drive mad.
  Réponse avec citation
Vieux 12/11/2007, 14h12   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: capturing a return code

On 2007-11-12, Jim Showalter <jshowalter@gmail.com> 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@opus.ynet Mon Nov 12 04:17:56 2007
> X-Original-To: droid
> Delivered-To: droid@opus.ynet
> From: droid@opus.ynet
> To: droid@opus.ynet
> 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.
  Réponse avec citation
Vieux 13/11/2007, 07h26   #3
droid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: capturing a return code

On Nov 12, 9:12 am, Bill Marcum <marcumb...@bellsouth.net> wrote:
>
> 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.


Good idea, Bill. I will try that tonight and post findings here.
There must
be some problem files causing an error return, because the server is
Unix.

  Réponse avec citation
Vieux 13/11/2007, 11h13   #4
droid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: capturing a return code

> On Nov 12, 9:12 am, Bill Marcum <marcumb...@bellsouth.net> wrote:
>
>
>
> > 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.


Good suggestions, Bill. I added "echo "return code=$val"" and used "-
d ncftpget.log". The server is Linux, so that is not the problem.
The latest cron message has:

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

The ncftpget.log file is 805954 bytes - ncftpget does a lot of
business! But grepping it for "error", "fail" and "warn" returns
nothing.

Could return code 3 be set by the server message, "File successfully
transferred" instead of by ncftpget?

  Réponse avec citation
Vieux 13/11/2007, 20h02   #5
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: capturing a return code

On 2007-11-13, droid <jshowalter@gmail.com> wrote:
>> On Nov 12, 9:12 am, Bill Marcum <marcumb...@bellsouth.net> wrote:
>>
>>
>>
>> > 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.

>
> Good suggestions, Bill. I added "echo "return code=$val"" and used "-
> d ncftpget.log". The server is Linux, so that is not the problem.
> The latest cron message has:
>
> bak_website: Now archiving http://mywebsite.com
> ncftpget: server said: File successfully transferred
> return code=3
> bak_website failed
>
> The ncftpget.log file is 805954 bytes - ncftpget does a lot of
> business! But grepping it for "error", "fail" and "warn" returns
> nothing.
>

Could you post a sample of that file, maybe the first or last 20
lines?

> Could return code 3 be set by the server message, "File successfully
> transferred" instead of by ncftpget?
>

That should not happen. Maybe you could try changing http:// to ftp://.

Have you tried getting files manually one at a time to see if you get an
error? Or you might try a loop like this:

until ncftpget -R http://mywebsite.com; do sleep 60; done

By default, ncftpget should try to resume a failed transfer, but this
might be a waste of time if the transfer failed for reasons other than
a broken connection (e.g. permission problems, i/o errors or disk full).

  Réponse avec citation
Vieux 13/11/2007, 22h08   #6
droid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: capturing a return code

On Nov 13, 3:02 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:::
>
> Could you post a sample of that file, maybe the first or last 20
> lines?


Output of "tail -n 20 ncftpget.log"

Cmd: MDTM stats/index.html
213: 20071112130935
Cmd: PASV
227: Entering Passive Mode (208,109,181,123,187,244)
Cmd: RETR stats/index.html
150: Accepted data connection
226: File successfully transferred
0.000 seconds (measured here), 15.92 Mbytes per second
Cmd: MDTM stats/navfile.html
213: 20071112130935
Cmd: PASV
227: Entering Passive Mode (208,109,181,123,250,77)
Cmd: RETR stats/navfile.html
150: Accepted data connection
4.1 kbytes to download
226: File successfully transferred
0.000 seconds (measured here), 118.22 Mbytes per second
Cmd: QUIT
221: Goodbye. You uploaded 0 and downloaded 18481 kbytes.
Logout.

>
> > Could return code 3 be set by the server message, "File successfully
> > transferred" instead of by ncftpget?

>
> That should not happen. Maybe you could try changing http:// to ftp://.


The ncftpget command line does access "ftp://mywebsite.com" (see my
first post). The "http://" thing is just the echo line.

>
> Have you tried getting files manually one at a time to see if you get an error?


I've used get from plain ftp and also mirrored the entire site using
wget. Or did you mean: use ncftpget to get files one-at-a-time?

>
> Or you might try a loop like this: until ncftpget -Rhttp://mywebsite.com;do sleep 60; done
>
> By default, ncftpget should try to resume a failed transfer, but this
> might be a waste of time if the transfer failed for reasons other than
> a broken connection (e.g. permission problems, i/o errors or disk full).


You really think it's an error then? I'm not sure. I get consistent
results every run, the total bytes downloaded increase just a little
each day, as you would expect. Also, the total bytes are just
slightly less than what I get with wget, which makes sense because
wget adds a ".listing" file to each directory.

But I'm not familiar with any of this stuff so I really appreciate
your . If you want the entire ncftp.log, I could email it to you.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h18.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19648 seconds with 14 queries