in reply to Re^2: Open directory - Different Server
in thread Open directory - Different Server

So you can use the Net::FTP module which is part of the libnet bundle. See the Synopsis in the modules docs for a good example.


holli, /regexed monk/
  • Comment on Re^3: Open directory - Different Server

Replies are listed 'Best First'.
Re^4: Open directory - Different Server
by Anonymous Monk on Feb 22, 2006 at 16:52 UTC
    Hi, I am getting connected using FTP, but when I run this part of the code it can't retrieve the names of the images files in the directory specified earlier.
    # Change the working directory $ftp->cwd($path) or die "Can't change directory ($host):" . $ftp->message; # Retrieve a recursive directory listing @ls = $ftp->ls('-lR'); $ftp->binary(); foreach $file (parse_dir(\@ls)) { my($name) = @$file; print "$name<br>"; }

    I just don't know why, since the path to the directory is right, and there are many images in that directory.
      From the docs:
      ls ( DIR )
      Get a directory listing of DIR, or the current directory.
      In an array context, returns a list of lines returned from the server. In a scalar context, returns a reference to a list.
      So your code should read
      # Retrieve a recursive directory listing @ls = $ftp->ls(); foreach $file ( @ls ) { print "$file<br>"; }


      holli, /regexed monk/
        Thank you, it work!