Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

NET::FTP: ls command fails

by esskar (Deacon)
on Sep 22, 2006 at 07:50 UTC ( #574340=perlquestion: print w/ replies, xml ) Need Help??
esskar has asked for the wisdom of the Perl Monks concerning the following question:

Hi, i'm trying to setup a ls command using Net::FTP. First, i show you my code
my $ftp = Net::FTP->new( $row->{ftp_host}, Debug => 1) or die "Cannot connect to " . $row->{ftp_host} . ": $@"; $ftp->login($row->{username}, $row->{password}) or die "Cannot login ", $ftp->message; $ftp->cwd("/logs/web") or die "Cannot change working directory ", $ftp->message; $ftp->pasv; my @dir = $ftp->ls; # <-- LINE 50
the trace looks as follows:
Net::FTP>>> Net::FTP(2.75) + Net::FTP>>> Exporter(5.58) + Net::FTP>>> Net::Cmd(2.26) + Net::FTP>>> IO::Socket::INET(1.27) + Net::FTP>>> IO::Socket(1.28) + Net::FTP>>> IO::Handle(1.24) + Net::FTP=GLOB(0x8521bbc)<<< 220 Microsoft FTP Service + Net::FTP=GLOB(0x8521bbc)>>> user xxxxxxxxxx + Net::FTP=GLOB(0x8521bbc)<<< 331 Password required for xxxxxxxxxx. + Net::FTP=GLOB(0x8521bbc)>>> PASS .... + Net::FTP=GLOB(0x8521bbc)<<< 230 User xxxxxxxxxx logged in. + Net::FTP=GLOB(0x8521bbc)>>> CWD /logs/web + Net::FTP=GLOB(0x8521bbc)<<< 250 CWD command successful. + Net::FTP=GLOB(0x8521bbc)>>> PASV + Net::FTP=GLOB(0x8521bbc)<<< 227 Entering Passive Mode (64,74,223,25,15 +,182). Net::FTP=GLOB(0x8521bbc)>>> PORT 192,168,1,101,130,121 + Net::FTP: Unexpected EOF on command channel at getenomlogs.pl line 50 +
I googled abou the 'Unexpected EOF on command channel' error, and it seems to be a aktiv <=> passiv FTP problem. But i already did entering passiv mode (i also have to check this option in my ftp client to get a proper connection) but why is Net::FTP setting up a PORT command - isn't that the command for establishing an aktiv connection?

Does anybody know what to do?

Comment on NET::FTP: ls command fails
Select or Download Code
Replies are listed 'Best First'.
Re: NET::FTP: ls command fails
by laceytech (Pilgrim) on Sep 22, 2006 at 16:42 UTC
    I have not used Net::FTP but I have found this link to be informative about active / passive transactions
Re: NET::FTP: ls command fails
by jesuashok (Curate) on Sep 22, 2006 at 08:41 UTC
    esskar,

    use Net::FTP; my $ftp = Net::FTP->new( "192.168.10.240", Debug => 1) or die "Cannot connect to " . "192.168.10.240" . ": $@"; $ftp->login("metrica", "metrica") or die "Cannot login ", $ftp->message; $ftp->cwd("/apps/inst1/metrica") or die "Cannot change working directory ", $ftp->message; $ftp->pasv; my @dir = $ftp->ls; # <-- LINE 50 print "Files :" , join('-',@dir), "\n";
    I executed the above code and it worked fine for me.
    Trace output
    C:\Perl>perl l.pl Net::FTP>>> Net::FTP(2.75) Net::FTP>>> Exporter(5.58) Net::FTP>>> Net::Cmd(2.26) Net::FTP>>> IO::Socket::INET(1.29) Net::FTP>>> IO::Socket(1.29) Net::FTP>>> IO::Handle(1.25) Net::FTP=GLOB(0x18331d8)<<< 220 osmosis FTP server ready. Net::FTP=GLOB(0x18331d8)>>> user metrica Net::FTP=GLOB(0x18331d8)<<< 331 Password required for metrica. Net::FTP=GLOB(0x18331d8)>>> PASS .... Net::FTP=GLOB(0x18331d8)<<< 230 User metrica logged in. Net::FTP=GLOB(0x18331d8)>>> CWD /apps/inst1/metrica Net::FTP=GLOB(0x18331d8)<<< 250 CWD command successful. Net::FTP=GLOB(0x18331d8)>>> PASV Net::FTP=GLOB(0x18331d8)<<< 227 Entering Passive Mode (192,168,10,240, +227,44) Net::FTP=GLOB(0x18331d8)>>> PASV Net::FTP=GLOB(0x18331d8)<<< 227 Entering Passive Mode (192,168,10,240, +227,44) Net::FTP=GLOB(0x18331d8)>>> NLST Net::FTP=GLOB(0x18331d8)<<< 150 Opening ASCII mode data connection for + file list . Net::FTP=GLOB(0x18331d8)<<< 226 Transfer complete. Files :AlarmManagement-CS-DBElements-DBLoader-DBServices-DataSources-E +xtenders-E xternal-GroupingService-Installer-MLEditor-MetaLayer-PMhelp-ReportDesi +gner-Repor ting-SPRegistry-Security-StartStop-SystemManagement-SystemTPhelp-Techn +ologyPacks -Uiweb-antony.txt-cell-tch-REPRT_0610-export-config-file.xml-cell-tch- +argan-expo rt-config-file.xml-cell-tch-rflosses-export-config-file.xml-cell_voice +_traffic_r aw_spr-param.xml-etc-ext-install_setup.ksh-logs-maeve-metrica_healthch +eck.html-n ohup.out-one.pl-setup.ksh-setup.tpl-setup_appserver.ksh-setup_informix +.ksh-setup _java.ksh-setup_openfusion.ksh-update3FFPromo.pl-utils

    "Keep pouring your ideas"
      yes; i think it may be a problem with the MS Ftp Server. But i do no know.

      and there is actually a difference. In your case, no PORT command is send to server; so it is working. But somehow, in my case it is sending a PORT command; maybe i should try to call NLST directly

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://574340]
Approved by tinita
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2015-07-28 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls