in reply to Re: Net::FTP Woes
in thread Net::FTP Woes

#/usr/bin/perl -w use strict; use warnings; ########################################################### # # rpasafe.pl -- robot propagator attempt # ########################################################### use Net::FTP; my $host = 'ftp.ftpserver.com'; my $u = 'user'; my $p = 'pass'; my $ftp; unless ($ftp = Net::FTP->new($host)) { die "No FTP for you!\n\n"; } $ftp->login($u, $p); $ftp->binary; my @lines = $ftp->dir(); print join("\n", @lines), "\n";
Sigh. Typo upon typo -- thanks for catching the error :) Just ran the above...
C:\WINDOWS\Profiles\Gregory\Desktop\LLPSV>perl rpasafe.pl C:\WINDOWS\Profiles\Gregory\Desktop\LLPSV>
Again, it seems that nothing's being returned as the main directory.

Any ideas? The FTP server definately exists and works -- I've logged in with an FTP client.

-----------------------
You are what you think.

Replies are listed 'Best First'.
Re: Re: Re: Net::FTP Woes
by demerphq (Chancellor) on Feb 04, 2003 at 00:03 UTC
    why not run it under debug and see what happens?
    my $Debug=1; unless ($ftp = Net::FTP->new($host,Debug=>$Debug)) { die "No FTP for you!\n\n"; }

    --- demerphq
    my friends call me, usually because I'm late....

Re: Re: Re: Net::FTP Woes
by tachyon (Chancellor) on Feb 04, 2003 at 00:10 UTC

    This works fine with my ftp servers. Setting the Degug level to 1 should tell you the problem (probably a login failure given your output). You can add or die "Blah" to all of your ftp method calls as they return true if they succeed and false if they fail BTW:

    use Net::FTP; my $host = 'yoursite.com'; my $u = 'user'; my $p = 'pass'; my $ftp = Net::FTP->new($host, Debug => 1) or die "No FTP for you!\n\n +"; $ftp->login($u, $p) or die "Login failed user:$u pass:$p\n"; $ftp->binary; print "The CWD is: ", $ftp->pwd(), "\n\n"; print "The contents of the dir:\n", join("\n", $ftp->dir()), "\n";

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      The new code incorporates the switchable debug level (set to 5) and running it again produced the following:
      Net::FTP: Net::FTP(2.65) Net::FTP: Exporter(5.562) Net::FTP: Net::Cmd(2.21) Net::FTP: IO::Socket::INET(1.25) Net::FTP: IO::Socket(1.26) Net::FTP: IO::Handle(1.21) Net::FTP=GLOB(0x1badea4)<<< 220 ProFTPD 1.2.7 Server (FTP Server) [som +e.ftp.com] Net::FTP=GLOB(0x1badea4)>>> user user Net::FTP=GLOB(0x1badea4)<<< 331 Password required for user. Net::FTP=GLOB(0x1badea4)>>> PASS .... Net::FTP=GLOB(0x1badea4)<<< 230 User user logged in. Net::FTP=GLOB(0x1badea4)>>> TYPE I Net::FTP=GLOB(0x1badea4)<<< 200 Type set to I. Net::FTP=GLOB(0x1badea4)>>> PWD Net::FTP=GLOB(0x1badea4)<<< 257 "/" is current directory. The CWD is: / Net::FTP=GLOB(0x1badea4)>>> PORT 65,235,148,119,18,190 Net::FTP=GLOB(0x1badea4)<<< 200 PORT command successful Net::FTP=GLOB(0x1badea4)>>> LIST Net::FTP=GLOB(0x1badea4)<<< 425 Unable to build data connection: Opera +tion timed out The contents of the dir:
      I firmly believe you when you say it works with your FTP server -- it should work.

      I set the timeout to 500 seconds, and it still timed out -- so I'm thinking the problem is something related to my installation of Net::FTP. I'm going to attempt reinstall and try to answer some of the questions differently -- any suggestions on which to answer, which way to answer them, or am I headed off in the wrong direction altogether?

      UPDATE

      I just did a reinstall on Net::FTP, and that has apparently been the whole problem. Thanks to all three of you for the patience you've shown with me -- FTP is something I'm a stranger to, but not quite so much any more. :)

      -----------------------
      You are what you think.