[lug] wget question

D. Stimits stimits at idcomm.com
Mon Jun 3 11:09:54 MDT 2002


Jim Buzbee wrote:
> 
> D. Stimits wrote:
> > Jim Buzbee wrote:
> >
> >>Anyone have expertise with wget ?
> >>
> >>I've been trying to convince wget to fetch a file for me without much
> >>luck. I'm using an ftp url with embedded username and password. e.g. :
> >>
> >>ftp://user:password@host/
> >>
> >>My problem is that the file I want to get is one directory above the
> >>login directory, i.e. ftp://user:password@host/../MYFILE - But wget
> >>seems to ignore the .. path.  If I interactively ftp in, I can get the
> >>file without issue so it's not any sort of permission problem.
> >
> >
> > I would have to wonder about the ".." in the path, it is a relative
> > path. The above URL is not legit in most cases, it says to go to the ftp
> > root (usually "/" unless it is a chroot environment, in which case ".."
> > must be ignored or else allow the session to exit the chroot jail
> > environment) and then to the parent of the ftp root...which is outside
> > of the ftp space. I would double check that the ".." is legitimate, wget
> > is probably doing the right thing. My guess is that manual login is
> > tolerant of error, and wget stops when it sees the error (as it should).
> 
> I don't think it's a chroot issue because manual ftp works fine. If the
> ftp daemon were running in a chroot jail, I wouldn't be able to do "cd
> .." "get README" successfully. I wonder if wget is trying to do some
> security restrictions on its own. Here's the output I see :

You can always do "cd ..", it is a defined interface command. The
difference between the root and subdirectories is that "cd .." from root
is defined to return the current directory, instead of a parent.

> 
>   wget -O - ftp://user:mypasswd@machine1/../README
> --10:05:02--  ftp://user:xxxxxxxx@machine1:21/README

The two above are the same thing, except for the null operation of "cd
..". The null operation I believe is returning a message that wget takes
as failure. John Hernandez mentioned using a full path, this would be
advisable. Some testing with wget though shows that wget assumes the
home directory of the given user. The following will get file README
from the home directory of "user":
  wget -O - ftp://user:mypasswd@machine1/README

If you place a file in the parent to the home directory, and use "..",
it will fail (at least my wget does). However, I think the trick you are
looking for is to use absolute path, which under wget requires a double
forward slash at the front of the path, "//":
  wget -O - ftp://user:mypasswd@machine1//Some/Absolute/Path/README

D. Stimits, stimits at idcomm.com

>             => `-'
> Connecting to machine1:21... connected!
> Logging in as user ... Logged in!
> ==> TYPE I ... done.  ==> CWD not needed.
> ==> PORT ... done.    ==> RETR README ...
> No such file `README'.
>



More information about the LUG mailing list