Net::FTP

L

lucas

having trouble listing the files using Net::FTP:

print ">Connecting...";
my $ftp = Net::FTP->new($addy, Port => $port, Debug => $debug) || die
"Could Not Connect\n";
print "Done\n";

print ">Logging in...";
$ftp->login($user,$pass) || die "Can't Log In\n";
print "Done\n";

print ">Listing files...";
@_ = $ftp->ls();
print "Done\n";
print "@_\n";

this code returns:

Net::FTP=GLOB(0x82de9d8)>>> PORT 192,168,0,2,129,26
Net::FTP=GLOB(0x82de9d8)<<< 200 PORT command successful.
Net::FTP=GLOB(0x82de9d8)>>> NLST
Net::FTP=GLOB(0x82de9d8)<<< 150 Opening ASCII mode data connection for file
list.
Net::FTP=GLOB(0x82de9d8)<<< 226 Transfer complete.
Listing files...Done
ARRAY(0x8308ef8)

printing @_ just shows "ARRAY(0x8308ef8)". this is the way it's done in the
examples. anybody know what's wrong with it?

regards,
 
P

Paul Lalli

lucas said:
having trouble listing the files using Net::FTP:

print ">Connecting...";
my $ftp = Net::FTP->new($addy, Port => $port, Debug => $debug) || die
"Could Not Connect\n";
print "Done\n";

print ">Logging in...";
$ftp->login($user,$pass) || die "Can't Log In\n";
print "Done\n";

print ">Listing files...";
@_ = $ftp->ls();
print "Done\n";
print "@_\n";

this code returns:

Net::FTP=GLOB(0x82de9d8)>>> PORT 192,168,0,2,129,26
Net::FTP=GLOB(0x82de9d8)<<< 200 PORT command successful.
Net::FTP=GLOB(0x82de9d8)>>> NLST
Net::FTP=GLOB(0x82de9d8)<<< 150 Opening ASCII mode data connection for file
list.
Net::FTP=GLOB(0x82de9d8)<<< 226 Transfer complete.


ARRAY(0x8308ef8)

printing @_ just shows "ARRAY(0x8308ef8)". this is the way it's done in the
examples. anybody know what's wrong with it?

That script works fine for me with Perl 5.8.0 on Solaris, using Net::FTP
2.65. Have you examined the contents of @_ using Data::Dumper to see
what's actually in the reference @_ contains? Try adding these lines:

use Data::Dumper;
print Dumper(\@_);

Also, what versions of Perl and Net::FTP are you using?
perl -v
perl -MNet::FTP -e'print $Net::FTP::VERSION;'

If you're not using at least Perl 5.80 and Net::FTP 2.65, consider
upgrading.
 
L

lucas

Paul said:
That script works fine for me with Perl 5.8.0 on Solaris, using Net::FTP
2.65. Have you examined the contents of @_ using Data::Dumper to see
what's actually in the reference @_ contains? Try adding these lines:

use Data::Dumper;
print Dumper(\@_);

Also, what versions of Perl and Net::FTP are you using?
perl -v
perl -MNet::FTP -e'print $Net::FTP::VERSION;'

If you're not using at least Perl 5.80 and Net::FTP 2.65, consider
upgrading.

i am running perl v5.8 and Net::FTP v2.70. DataDumper did work and printed
out:

$VAR1 = [
[
'Games X Copy',
'index.html',
'EasyOS.zip',
]
];

i was hoping to be able to just get a plain file list, but i can make this
work. thanks for your help
 
G

Gunnar Hjalmarsson

lucas said:
DataDumper did work and printed out:

$VAR1 = [
[
'Games X Copy',
'index.html',
'EasyOS.zip',
]
];

That means that @_ contains one element ( $_[0] ), which is an array
reference.
i was hoping to be able to just get a plain file list,

Just dereference the array reference:

my @files = @{ $_[0] };

perldoc perlreftut
perldoc perlref
 
L

lucas

Gunnar said:
lucas wrote:
That means that @_ contains one element ( $_[0] ), which is an array
reference.
i was hoping to be able to just get a plain file list,

Just dereference the array reference:

my @files = @{ $_[0] };

perldoc perlreftut
perldoc perlref

ah, that's exactly what i needed, thx
 
B

bala

Hi,

Does anyone know why Net::FTP does not support nmap?

I did check the documentation.

Is there any alternative?

Ta.
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top