For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > March 2005 > Net::FTP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Net::FTP
lucas

2005-03-22, 3:58 pm

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,
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
Paul Lalli

2005-03-22, 3:58 pm

lucas wrote:
> 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.
lucas

2005-03-22, 8:58 pm

Paul Lalli wrote:

> 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
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
Gunnar Hjalmarsson

2005-03-22, 8:58 pm

lucas wrote:
> 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

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
lucas

2005-03-23, 8:57 pm

Gunnar Hjalmarsson wrote:

> lucas wrote:
> That means that @_ contains one element ( $_[0] ), which is an array
> reference.
>
>
> Just dereference the array reference:
>
> my @files = @{ $_[0] };
>
> perldoc perlreftut
> perldoc perlref


ah, that's exactly what i needed, thx
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
bala

2005-03-26, 3:57 pm

Hi,

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

I did check the documentation.

Is there any alternative?

Ta.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com