Net::FTP

Discussion in 'Perl Misc' started by lucas, Mar 22, 2005.

  1. lucas

    lucas Guest

    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;
    -------------------------
     
    lucas, Mar 22, 2005
    #1
    1. Advertising

  2. lucas

    Paul Lalli Guest

    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.
    >
    >>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?


    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.
     
    Paul Lalli, Mar 22, 2005
    #2
    1. Advertising

  3. lucas

    lucas Guest

    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;
    -------------------------
     
    lucas, Mar 22, 2005
    #3
  4. 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
     
    Gunnar Hjalmarsson, Mar 22, 2005
    #4
  5. lucas

    lucas Guest

    Gunnar Hjalmarsson wrote:

    > 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
    --
    lucas
    -------------------------
    Perl Coder since 2001
    shift || die;
    -------------------------
     
    lucas, Mar 23, 2005
    #5
  6. lucas

    bala Guest

    Hi,

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

    I did check the documentation.

    Is there any alternative?

    Ta.
     
    bala, Mar 26, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    5,659
  2. Vin Raja

    FTP : Time problem (net/ftp)

    Vin Raja, Jun 7, 2007, in forum: Ruby
    Replies:
    0
    Views:
    103
    Vin Raja
    Jun 7, 2007
  3. Ari Brown

    Net::FTP and ftp.dir()

    Ari Brown, Jul 16, 2007, in forum: Ruby
    Replies:
    0
    Views:
    88
    Ari Brown
    Jul 16, 2007
  4. Jeff Miller
    Replies:
    0
    Views:
    504
    Jeff Miller
    Mar 26, 2009
  5. D. Buck
    Replies:
    2
    Views:
    493
    D. Buck
    Jun 29, 2004
Loading...

Share This Page