ls in ftp fails

M

mike

Hi,

I connect to a remote ftp site:

I see the following from the script:

Directory is /mirror/eclipse/technology/epp/downloads/release/galileo/
SR2

I cannot list the files in the directory $current_dir.

The line that fails is:

my @files=$ftp -> ls("$current_dir") or die "Could not list files. $!
\n";

Any idea what I am doing wrong? All help is very much appreciated.

//mike

Code:
use strict;
use warnings;
use Net::FTP;

my $message;

my $hostname ="ftp.ing.umu.se";

my $remote_dir = "/mirror/eclipse/technology/epp/downloads/release/
galileo/SR2/";

my $ftp = Net::FTP -> new ($hostname,Timeout => 30,Debug => 0) or
die "Cannot access $hostname via FTP\n";

$ftp -> login("anonymous",'-anonymous@') or
die "Invalid user name and/or password\n",$ftp-> $message;

$ftp->binary();
$ftp->cwd("$remote_dir") or die "Couldn't change directory. $!", $ftp->
$message;
my $current_dir = $ftp -> pwd();
print ("Directory is $current_dir \n");

my @files=$ftp -> ls("$current_dir") or die "Could not list files. $!
\n";

foreach my $file (@files){
print "$file \n";
}
 
S

smallpond

Hi,

I connect to a remote ftp site:

I see the following from the script:

Directory is /mirror/eclipse/technology/epp/downloads/release/galileo/
SR2

I cannot list the files in the directory $current_dir.

The line that fails is:

my @files=$ftp -> ls("$current_dir") or die "Could not list files. $!
\n";

Any idea what I am doing wrong? All help is very much appreciated.

Yes. What you are doing wrong is not telling us what error got
printed
by the die, The whole point of the die instruction is to print out
that informative little $! thingy.
 
P

Peter Makholm

mike said:
The line that fails is:

my @files=$ftp -> ls("$current_dir") or die "Could not list files. $!
\n";

In the documentation for Net::FTP I see no sign of $! having any
significance to errors in the module. The synopsis have examples of
error handling using $ftp->message. It might be more helpful.

(Not that the message method is actually documentes. *sigh*)

//Makholm
 
O

Ohhhh maaan

mike said:
Hi,

I connect to a remote ftp site:

I see the following from the script:

Directory is /mirror/eclipse/technology/epp/downloads/release/galileo/
SR2

I cannot list the files in the directory $current_dir.

The line that fails is:

my @files=$ftp -> ls("$current_dir") or die "Could not list files. $!
\n";

Works for me, try setting PASV mode or not, because it's likely a
firewall issue that's blocking the listing.
 
M

mike

Works for me, try setting PASV mode or not, because it's likely a
firewall issue that's blocking the listing.

Thanks for all helpful pointers. I had a typo i my code. I was
supposed to be message and not $message.

//mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top