Page 1 of 1
Detecting symlinks in FTP directories
Posted: Wed Sep 12, 2012 4:43 pm
by paulclaude
While listing a FTP directory, I often find symbolic links and the listing script stops with this error:
"error 550 can't change directory to /stats/logs -> =mnt/log159756: no such file or directory"
that, in the FTP list, appears something like:
Code: Select all
lrwxrwxrwx 1 544 544 34 Oct 22 2011 /stats/logs -> mnt/log159756
I only need to avoid symbolic links, not to resolve them. But how can I detect them in a FTP list?
Thanks for the help....
Re: Detecting symlinks in FTP directories
Posted: Wed Sep 12, 2012 5:26 pm
by jacque
The permissions on a symbolic link are always lrwxrwxrwx. This means that anyone can see where the links points. Who can read, write, or execute the file (or directory or device) the link points to is determined by the permissions on that file, not the link.
From here:
http://oldfield.wattle.id.au/luv/permissions.html
Re: Detecting symlinks in FTP directories
Posted: Wed Sep 12, 2012 5:43 pm
by paulclaude
Thank you, Jaqueline. I can avoid all permissions "lrwxrwxrwx", or better all list entries beginning with "l": but how can I do with other FTP list formats?
ES: a Windows FTP server returns a directory list like:
Code: Select all
08-24-09 01:44PM 1754 _vti_inf.html
10-13-05 09:13AM <DIR> Incoming
Re: Detecting symlinks in FTP directories
Posted: Thu Sep 13, 2012 5:34 am
by shaosean
The built FTP functionality (libURL) does not support all server types which means some servers will cause your application to return the wrong results.. Also, libURL closes the connection after each command sent - this causes your application to re-open a connection every time you send a command.. This causes your application to be slower and less responsive, and may also trigger server-side security features.. And the final issue I have with it, is it can only send one command at a time (no queuing of commands)..
I spent a good couple of months researching all the different server types and writing a parser for them (I currently do not support the VMS FTP file listings).. I spent the next few years writing and re-writing my library due to the changes in Rev (went from a library to a behaviour and now it is a DropTools control).. The built-in FTP is good enough for most uses, but when you need something better, you will need to do the work yourself..
Re: Detecting symlinks in FTP directories
Posted: Thu Sep 13, 2012 8:32 am
by paulclaude
Unfortunately I do not have the competence needed to develop a new FTP library. For now, it would be enough to me to identify the symlinks in UNIX and Windows FTP list formats, which are the most popular.
Re: Detecting symlinks in FTP directories
Posted: Fri Sep 14, 2012 5:04 am
by shaosean
I believe NT servers give the UNIX listings and non-NT gives a DOS-like listing..