Hello,

I need to make two scripts 'ftp-file-exist' and 'ftp-dir-exist' . My scripts
shall accept  4 parameters (SERVER USER PASSWORD REMOTE-PATH)
and  return exist status (and print short message) telling  whether
the path does not exist, or is plain file, or is a directory.
(It's like 'test -f', 'test -d' do, only via ftp).
I want to understand whcih lftp commands shall I use to do this
with minimum overhead.

Especially, is it possible to check for file/dir existance without
opening additional data socket ? Some people say to use rename and then
check for return code 350 (file exists). I'm not sure if this is good. Is it good ? I think if filesystem is read-only, then server can fail the rename request with differenr error code, no ?

How do I issue NLST using lftp ? If I use NLST, how do I tell if this is plain file, or directory ?

And if I use dir, then I have two questions
(1) how do I avoid listing of the dir contents, in case the tested name happens to be a dir ?
(2) is lftp listing format server-independent ?

Regarding checking the dir existance, I am even less sure how to do it:

- how I basically check if directory exists, with minimum overhead ?
- how do I avoid listing of the contents if this happens to be a dir ?
 (sort of like 'ls -d)
- can I check for dir existance without opening data socket ?

Thanks
Yakov Lerner


Reply via email to