Subject: | Undefined value Net-FTP-2.77 dataconn.pm line 54 |
Date: | Tue, 28 Jul 2009 11:32:07 +0800 |
To: | bug-libnet [...] rt.cpan.org |
From: | Tom Shaw <tom.shaw [...] solidsystems.com.au> |
Perl: **This is perl, v5.8.9 built for sun4-solaris
OS: SunOS hubint 5.10 Generic_141414-01 sun4u sparc SUNW,SPARC-Enterprise
Error: Can't use an undefined value as a symbol reference at
/opt/WNGperl5/lib/5.8.9/Net/FTP/dataconn.pm line 54.
Also seen using the built-in Perl 5.8.4 from Solaris 10 on a different SPARC
machine.
The server is "Microsoft FTP Service"
This seems to be a race condition caused by using the $ftp->list($filename)
method. It is likely I am using this method incorrectly, and not handling
the dataconn correctly - if so, can I suggest that the documentation be
updated to advise users that the "low-level" functions like $ftp->list can
interfere with other Net::FTP commands if they are not handled correctly.
The documentation currently says:
If for some reason you want to have complete control over the data
connection, this includes generating it and calling the response method when
required, then the user can use these methods to do so.
However calling these methods only affects the use of the methods above that
can return a data connection. They have no effect on methods get, put,
put_unique and those that do not require data connections.
"These methods" is ambiguous - I assume it means the methods listed above.
It seems that the second paragraph here is incorrect as "these methods" do
affect the other methods.
There arre a few posts on various forums about the line 54 error, as yet not
answered.
*Steps to reproduce*
#!/usr/bin/perl -w
use strict;
use Net::FTP;
my $host="hostname";
my $server="server";
my $uname ="user";
my $pword ="password";
my $rdir ="directory";
my $filename1 = "test1";
my $filename2 = "test2";
my $ftp = Net::FTP->new($server, Debug => 1)
or die ("Could not connect to server $server");
$ftp->login($uname,$pword)
or die ("$host cannot login to server $server: " . $ftp->message);
$ftp->cwd("$rdir")
or exitscript($ftp->code(),"$host cannot change remote working
directory: " . $ftp->message);
$ftp->ascii
or die("$host cannot set transfer mode: " . $ftp->message);
$ftp->put($filename1);
$ftp->list($filename1);
$ftp->put($filename2);
$ftp->list($filename2);
$ftp->quit();
exit 1;
*Output*
(using the debugger to get a good stack trace)
# perl -d 1.pl
Loading DB routines from perl5db.pl version 1.31
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(1.pl:7): my $host="hostname";
DB<1> c
Net::FTP>>> Net::FTP(2.77)
Net::FTP>>> Exporter(5.63)
Net::FTP>>> Net::Cmd(2.29)
Net::FTP>>> IO::Socket::INET(1.31)
Net::FTP>>> IO::Socket(1.30)
Net::FTP>>> IO::Handle(1.27)
Net::FTP=GLOB(0x23d944)<<< 220 Microsoft FTP Service
Net::FTP=GLOB(0x23d944)>>> USER username
Net::FTP=GLOB(0x23d944)<<< 331 Password required for username.
Net::FTP=GLOB(0x23d944)>>> PASS ....
Net::FTP=GLOB(0x23d944)<<< 230 User username logged in.
Net::FTP=GLOB(0x23d944)>>> CWD directory
Net::FTP=GLOB(0x23d944)<<< 250 CWD command successful.
Net::FTP=GLOB(0x23d944)>>> TYPE A
Net::FTP=GLOB(0x23d944)<<< 200 Type set to A.
Net::FTP=GLOB(0x23d944)>>> ALLO 6
Net::FTP=GLOB(0x23d944)<<< 200 ALLO command successful.
Net::FTP=GLOB(0x23d944)>>> PASV
Net::FTP=GLOB(0x23d944)<<< 227 Entering Passive Mode
(10,210,188,202,14,196).
Net::FTP=GLOB(0x23d944)>>> STOR test1
Net::FTP=GLOB(0x23d944)<<< 125 Data connection already open; Transfer
starting.
Net::FTP=GLOB(0x23d944)<<< 226 Transfer complete.
Net::FTP=GLOB(0x23d944)>>> PASV
Net::FTP=GLOB(0x23d944)<<< 227 Entering Passive Mode
(10,210,188,202,14,197).
Net::FTP=GLOB(0x23d944)>>> LIST test1
Net::FTP=GLOB(0x23d944)<<< 125 Data connection already open; Transfer
starting.
Net::FTP=GLOB(0x23d944)>>> ALLO 6
Net::FTP=GLOB(0x23d944)<<< 226 Transfer complete.
Net::FTP=GLOB(0x23d944)>>> PASV
Net::FTP=GLOB(0x23d944)<<< 200 ALLO command successful.
Net::FTP=GLOB(0x23d944)>>> PASV
Net::FTP=GLOB(0x23d944)<<< 227 Entering Passive Mode
(10,210,188,202,14,198).
Net::FTP=GLOB(0x23d944)>>> LIST test2
Can't use an undefined value as a symbol reference at
/opt/WNGperl5/lib/5.8.9/Net/FTP/dataconn.pm line 54.
at /opt/WNGperl5/lib/5.8.9/Net/FTP/dataconn.pm line 54
Net::FTP::dataconn::_close('Net::FTP::A=GLOB(0x5aeb8c)') called at
/opt/WNGperl5/lib/5.8.9/Net/FTP/dataconn.pm line 70
Net::FTP::dataconn::close('Net::FTP::A=GLOB(0x5aeb8c)') called at
/opt/WNGperl5/lib/5.8.9/sun4-solaris/IO/Socket/INET.pm line 118
IO::Socket::INET::_error('Net::FTP::A=GLOB(0x5aeb8c)', 'Illegal
seek', '') called at /opt/WNGperl5/lib/5.8.9/sun4-solaris/IO/Socket/INET.pm
line 237
IO::Socket::INET::configure('Net::FTP::A=GLOB(0x5aeb8c)',
'HASH(0x5ca910)') called at
/opt/WNGperl5/lib/5.8.9/sun4-solaris/IO/Socket.pm line 48
IO::Socket::new('Net::FTP::A', 'PeerAddr', 10.210.188.202,
'PeerPort', 3782, 'LocalAddr', undef, 'Proto', 'tcp', ...) called at
/opt/WNGperl5/lib/5.8.9/sun4-solaris/IO/Socket/INET.pm line 37
IO::Socket::INET::new('Net::FTP::A', 'PeerAddr', 10.210.188.202,
'PeerPort', 3782, 'LocalAddr', undef, 'Proto', 'tcp', ...) called at
/opt/WNGperl5/lib/5.8.9/Net/FTP.pm line 932
Net::FTP::_dataconn('Net::FTP=GLOB(0x23d944)') called at
/opt/WNGperl5/lib/5.8.9/Net/FTP.pm line 1014
Net::FTP::_data_cmd('Net::FTP=GLOB(0x23d944)', 'LIST', 'test2')
called at /opt/WNGperl5/lib/5.8.9/Net/FTP.pm line 677
Net::FTP::list('Net::FTP=GLOB(0x23d944)', 'test2') called at 1.pl
line 30
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
DB<1>
Note: this dies at the second "list" command. The FTP status codes etc have
become out-of-order.
Alternatively, if I am conscientious at doing:
$ftp->put($filename) or die ...
then the script dies at "Unable to put test2".
Regards
Tom Shaw