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

Sorry, I will be connecting using FTP
  • Comment on Re^2: Open directory - Different Server

Replies are listed 'Best First'.
Re^3: Open directory - Different Server
by neilwatson (Priest) on Feb 22, 2006 at 14:17 UTC
    I believe there is a Net::Ftp module in CPAN. Really, you should look at using SSH and the module Net::SSH instead. FTP is very insecure.

    Neil Watson
    watson-wilson.ca

Re^3: Open directory - Different Server
by holli (Abbot) on Feb 22, 2006 at 14:29 UTC
    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/
      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/