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.
| [reply] |
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.
| [reply] |
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. | [reply] [d/l] |
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>";
}
| [reply] [d/l] |