Re: LWP::Simple getstore with absolute path not working



On 2008-06-16 06:34, emrefan <dksleung@xxxxxxxxxxx> wrote:
On Jun 16, 5:55 am, "szr" <sz...@xxxxxxxxxxxxxxx> wrote:
You may want to test it in a browser and then in your script add checks
to catch cases where  adir or file doesn't exist.

   ftp://host/%2fdir-under-the-root/some-dir/some-file

where %2f is a url-encoded '/'; but strictly speaking this requires
your FTP server to support a chdir to '/dir-under-the-root' in one
go, which is not required. Most do, however.

It should support a chdir to / (if it has a directory called "/"), so
you should be able to write
ftp://host/%2f/dir-under-the-root/some-dir/some-file
then.


Why would it need to do that? Give that url, it should be going to
"/fdir-under-the-root/some-dir/some-file" in one go.

When a user logs in via ftp (including when the user is "anonymous"),
he is placed in wherever is considered his home directory and if this
home directory does not happen to be "/", then the URL with just a
slash after the hostname is not going to work as intended. I tested
that, had problems and so queried. With an "%2f" after the hostname,
it worked. I reckond I'd call that a bug in URI.pm & co. but at least
I now have a workaround.

It's not a bug. That's how FTP URIs are supposed to work. To quote from
RFC 1738:

| The url-path of a FTP URL has the following syntax:
|
| <cwd1>/<cwd2>/.../<cwdN>/<name>;type=<typecode>
|
| Where <cwd1> through <cwdN> and <name> are (possibly encoded) strings
| and <typecode> is one of the characters "a", "i", or "d".
[...]
| The url-path is interpreted as a series of FTP commands as follows:
|
| Each of the <cwd> elements is to be supplied, sequentially, as the
| argument to a CWD (change working directory) command.
|
| If the typecode is "d", perform a NLST (name list) command with
| <name> as the argument, and interpret the results as a file
| directory listing.
|
| Otherwise, perform a TYPE command with <typecode> as the argument,
| and then access the file whose name is <name> (for example, using
| the RETR command.)

So ftp://host/%2fdir-under-the-root/some-dir/some-file means:

Connect to host and log in as anonymous.
cwd /dir-under-the-root
cwd some-dir
retr some-file

Note that /dir-under-the-root is only a directory under the root on unix
and window systems. Other OSs may have other conventions (once upon a
time, FTP servers running VMS or IBM host OSs were common), and the host
OS may not even have the concept of a "root directory".

hp
.



Relevant Pages

  • Re: SYSCONF and FTPIT jobs
    ... belonging to the 192.168/16 netblock and is connected to the ftp host via ... I also have concerns about the generated ftpin file. ... 200 PORT command successful. ...
    (comp.sys.hp.mpe)
  • Re: libfetch ftp patch for less latency
    ... This might be a DOS ftp server thing however. ... there is an error to the all-in-one CWD, the code reverts back to legacy ... Also, considering the reply codes to the CWD command, only 421 seems to ...
    (freebsd-current)
  • Re: COMMONLY USED UNIX COMMANDS
    ... prog3, and prog3 in your directory, the Unix command: ... Telnet brings up the login prompt of remote host and expects you to ... ftp expects you to enter your username/passwd or if it is ftp only ...
    (comp.unix.solaris)
  • Re: ftp connection in VB.NET
    ... If I am sure there is a mailroot directory in the root directory on my ftp ... try to run the command as cwd /directoryname. ... ' this will let us enter the directory CurrentDirectory, ...
    (microsoft.public.dotnet.framework)
  • COMMONLY USED UNIX COMMANDS
    ... prog3, and prog3 in your directory, the Unix command: ... Telnet brings up the login prompt of remote host and expects you to ... ftp expects you to enter your username/passwd or if it is ftp only ...
    (comp.unix.solaris)