Hi,
I was talking about lftp find command, which is described here:
http://lftp.yar.ru/lftp-man.html
find [directory]
List files in the directory (current directory by default) recursively.
This can help with servers lacking ls -R support. You can redirect out-
put of this command.
So, I'm certainly not talking about UNIX find...
@Alexander: Maybe my request was confusing, I just wanted to know if it's
possible to have a check (with ls or find or whatever command) for existence of
several remote files and react on that check with a conditional exit command.
Regards,
Tilo
From: Peko [mailto:[email protected]]
Sent: Thursday, March 17, 2011 5:26 PM
To: Mütze, Tilo, NMI-OPP
Cc: [email protected]
Subject: Re: Question regarding find and glob
On 17 March 2011 16:07,
<[email protected]<mailto:[email protected]>> wrote:
Hi,
we want to exit lftp processing, when a file pattern is not matching.
This exits with RC=8, if no hugo.xml file is present:
find hugo.xml || exit 8;
Now for patterns:
glob find *.xml || exit 8;
doesn't work, if no *.xml files are there. It doesn't exit the processing.
Also:
find *.xml || exit 8;
doesn't work, as it seems that find does not accept patterns.
Any hint what must be done to conditionally check if multiple files are present
on remote site and exit with a specific RC if they aren't?
Thanks,
Tilo
Hi Tilo, Hi ListMembers.
Whenever you want to program and debug:
1) Make least assumption => Read The Fantastic Manual: You will read that
[find] return zero unless it could process normally.
enter [man find] and read EXIT STATUS chapter
So [find] will return zero if execution was normal, which does not mean that
some file was found or not.
2) For defensive/secure/debbug programming, use maximal explicit command: use
explicit arguments for [find]
find . -name "*.xml" -print
3) Develop a workaround
one solution may be testing [find] output
#!/bin/bash
# get find standard output, and skip standard error in a variable
found=$(find . -name "*.xml" -print 2>/dev/null)
# test it
if [[ ! -z ${found} ]] ; then
echo Files found:
echo ${found}
else
echo Not found
fi
--Peko