Hi Alexander,

first of all a happy new year 2011 to you!



In the meantime we've actually found out what you meant with "&&" (only if 
previous command returned zero status) and "||" (only if previous command 
returned non zero status). We are now using conditional execution in lftp in 
the following manner. We are having a find command to actually check if a 
remote file exist and if it doesn't exist, exit lftp processing with RC=8:

lftp -c "debug 5;

  set;

  open -u sftp_user,xxx sftp://sftp_server;

  cd remote_dir;

  lcd /local_dir;

  find tweety.txt || exit 8;

  get -E tweety.txt;

  quit;"



We get the following errors, if tweety.txt doesn't exist:

find: Access failed: No such file (/remote_dir/tweety.txt)

get: Access failed: No such file (tweety.txt)

The problem is, that lftp ends with RC=1 and not RC=8 and also the get-command 
is executed!



Then doing the same on command line using lftp interactively, it works as 
expected (the last RC is set to 8):

lftp :~> open -u sftp_user,xxx sftp://sftp_server;

lftp u...@sftp_server:~> cd remote_dir;

cd ok, cwd=/remote_dir

lftp u...@sftp_server:/remote_dir> find tweety.txt || exit 8;

find: Access failed: No such file (/remote_dir/tweety.txt)

f...@bar:~> echo $?

8



Could you give us a hint how we can use the conditional statement with "lftp 
-c"?



P.S.: We are using lftp 3.7.14 and some global settings like " set 
cmd:fail-exit yes;" are set in ~/.lftprc.



Thanks and regards,

Tilo



> -----Original Message-----

> From: [email protected] [mailto:[email protected]] On Behalf Of

> [email protected]

> Sent: Wednesday, December 01, 2010 5:05 PM

> To: [email protected]

> Cc: [email protected]

> Subject: RE: mget "No files found"

>

> Hi Alexander,

> if I understand correct, the last returncode, in this case "echo -n" which 
> always

> should be 0 is given back. Is this correct?

> Would it be a good idea to have a different return code, if no files are found

> (should be server reply 550 in case of FTP) than for other errors like 
> "connection

> can't be established" or a "permission denied"? This would make a specific 
> control

> possible, that allows the situation where no files are found at remote side.

>

> Thanks for your thoughts regarding this topic!

>

> Best regards,

> Tilo

>

> > -----Original Message-----

> > From: Alexander V. Lukyanov [mailto:[email protected]]

> > Sent: Thursday, November 25, 2010 4:00 PM

> > To: Mütze, Tilo, NMI-OPP

> > Cc: [email protected]

> > Subject: Re: mget "No files found"

> >

> > On Thu, Nov 25, 2010 at 12:10:15PM +0000, [email protected] wrote:

> > > we are using lftp in a batch processing with "cmd:fail-exit yes;" set. 
> > > Now there

> is

> > a requirement, that if no files are found during a "mget -E *"-command ("no 
> > files

> > found"), the whole processing continues, instead of having lftp fail with 
> > exit

> code

> > 1.

> >

> > Try:

> >       mget * || echo -n

> >

> > --

> >    Alexander.


Reply via email to