weird failure with Net::FTP

B

botfood

I have a script that goes out and backs up a list of files to my PC
nightly using Net::FTP which has been running successfully for months.
Today it crashes out with the following error:

Can't locate object method "new" via package "Net::FTP::ascii" at
C:/usr/lib/IO/Socket.pm line 253.

Nothing has changed in my config, the script, or anything else I can
think of.... what could be going on? should I re-install Net:FTP ?

I installed it using ppm from Activestate to my PC which is running
windows 98.

thanks,
d
 
B

botfood

....actually it looks like Net::FTP was part of the standard install for
this old version, not installed via ppm. but I am still stuck as to why
it breaks now. any thoughts?
 
B

botfood

also turns out that my remote host moved my account to a new piece of
hardware... but I can login via FTP manually the same as before, so I
dont see any difference in login options. Is there a chance that
Net::FTP may give an error like this if it can no longer establish a
connection that allows a get() ?
 
B

botfood

I'll see if I can get more info from the debug option. do you know
where the debug info goes? to a file?

I added a statement to print $@ after the new constructor, and it is
undef. The error doesnt crash the script until it attempts a get().

I just tested get() ing from a different host with my script, and it
works fine. I am now highly suspect that whatever my host did when they
moved my account to a different machine is the cause. I cant tell what
they changed though, because a manual FTP using WS_FTP still seems to
work fine.
 
B

botfood

I'll see if I can get more info from the debug option. do you know
where the debug info goes? to a file?

I'll see if anything shows up in $@

I just tested get() ing from a different host with my script, and it
works fine. I am now highly suspect that whatever my host did when they
moved my account to a different machine is the cause. I cant tell what
they changed though, because a manual FTP using WS_FTP still seems to
work fine.
 
B

botfood

I did add the Debug=>1 to the new() and got a log in the STDERR I
captured. Doesn't shed too much light though. looks ok until it tries
the RETR and then craps out.

Net::FTP: Net::FTP(2.33)
Net::FTP: Exporter
Net::FTP: Net::Cmd(2.11)
Net::FTP: IO::Socket::INET
Net::FTP: IO::Socket(1.1603)
Net::FTP: IO::Handle(1.1505)

Net::FTP=GLOB(0xc0061c)<<< 220---------- Welcome to Pure-FTPd [TLS]
----------
Net::FTP=GLOB(0xc0061c)<<< 220-You are user number 3 of 50 allowed.
Net::FTP=GLOB(0xc0061c)<<< 220-Local time is now 19:29. Server port:
21.
Net::FTP=GLOB(0xc0061c)<<< 220-IPv6 connections are also welcome on
this server.
Net::FTP=GLOB(0xc0061c)<<< 220 You will be disconnected after 15
minutes of inactivity.

Logging into xxxx.com
Net::FTP=GLOB(0xc0061c)>>> user xxxx

Net::FTP=GLOB(0xc0061c)<<< 331 User xxxx
OK. Password required
Net::FTP=GLOB(0xc0061c)>>> PASS ....
Net::FTP=GLOB(0xc0061c)<<< 230-User xxxxhas group access to: xxxx
Net::FTP=GLOB(0xc0061c)<<< 230 OK. Current restricted directory is /
Net::FTP=GLOB(0xc0061c)>>> TYPE ASCII

Net::FTP=GLOB(0xc0061c)<<< 200 TYPE is now ASCII
getting /public_html/index.html as type ASCII
Net::FTP=GLOB(0xc0061c)>>> PORT 68,35,3,131,5,180

Net::FTP=GLOB(0xc0061c)<<< 200 PORT command successful
Net::FTP=GLOB(0xc0061c)>>> RETR /public_html/index.html

Net::FTP=GLOB(0xc0061c)<<< 150-Connecting to port 1460
Net::FTP=GLOB(0xc0061c)<<< 150 6.0 kbytes to download
Can't locate object method "new" via package "Net::FTP::ASCII" at
C:/usr/lib/IO/Socket.pm line 253.
Net::FTP=GLOB(0xc0061c)>>> QUIT

Net::FTP=GLOB(0xc0061c)<<< 226-File successfully transferred
Net::FTP=GLOB(0xc0061c)<<< 226 0.000 seconds (measured here), 34.50
Mbytes per second
 
D

Dov Wasserman

I have had "bugs" in older versions of Net::FTP, such as everything
worked fine for months, then a file name with a space showed up making
the script fail. A higher version fixed the space problem. Try
upgrading to the latest version and see what happens. -lv

I was going to suggest something along these lines. Maybe as part of
your account being moved to a new machine, some file or pathname you are
trying to FTP has changed, like a space being added, or using DOS-style
back slashes '\' instead of unix-style forward slashes '/' for directory
delimiters. Try quoting the file or directory names you specify to copy.

If that doesn't work, post your code so more eyeballs can debug it.

Regards,

-Dov
 
B

botfood

I tried setting the Passive=>1 in the new() constructor, and I also set
the Timeout=>800 in case that was the issue. No change in behavior. I
did notice a couple things from the Debug to STDERR though.

It looks like the server does not understand the command "TYPE binary"
but it does accept "TYPE ascii", and it also looks like it increments
the port with each get(). Here is an excerpt of the log:

Net::FTP=GLOB(0xbfcda4)>>> MDTM
/public_html/employees/pilot_sched.shtml

Net::FTP=GLOB(0xbfcda4)<<< 213 20041217230850
getting /public_html/employees/pilot_sched.shtml as type ascii
Net::FTP=GLOB(0xbfcda4)>>> PORT 68,35,3,131,10,40

Net::FTP=GLOB(0xbfcda4)<<< 200 PORT command successful
Net::FTP=GLOB(0xbfcda4)>>> RETR
/public_html/employees/pilot_sched.shtml

Net::FTP=GLOB(0xbfcda4)<<< 150 Connecting to port 2600
Net::FTP=GLOB(0xbfcda4)<<< 226-File successfully transferred
Net::FTP=GLOB(0xbfcda4)<<< 226 0.000 seconds (measured here), 12.03
Mbytes per second
Net::FTP=GLOB(0xbfcda4)>>> TYPE binary

Net::FTP=GLOB(0xbfcda4)<<< 504-Unknown TYPE: binary
Net::FTP=GLOB(0xbfcda4)<<< 504 TYPE is now ASCII
Net::FTP=GLOB(0xbfcda4)>>> MDTM
/public_html/employees/cgi-bin/CertMan/DB_Certificates

Net::FTP=GLOB(0xbfcda4)<<< 213 20041229054819
getting /public_html/employees/cgi-bin/CertMan/DB_Certificates as
type binary
Net::FTP=GLOB(0xbfcda4)>>> PORT 68,35,3,131,10,41

Net::FTP=GLOB(0xbfcda4)<<< 200 PORT command successful
Net::FTP=GLOB(0xbfcda4)>>> RETR
/public_html/employees/cgi-bin/CertMan/DB_Certificates

Net::FTP=GLOB(0xbfcda4)<<< 150-Connecting to port 2601
Net::FTP=GLOB(0xbfcda4)<<< 150 12.0 kbytes to download
Net::FTP=GLOB(0xbfcda4)<<< 226-File successfully transferred
Net::FTP=GLOB(0xbfcda4)<<< 226 0.000 seconds (measured here), 50.50
Mbytes per second
Net::FTP=GLOB(0xbfcda4)>>> TYPE ascii
Net::FTP=GLOB(0xbfcda4)<<< 200 TYPE is now ASCII
 
B

botfood

I tried setting the Passive=>1 in the new() constructor, and I also set
the Timeout=>800 in case that was the issue. No change in behavior. I
did notice a couple things from the Debug to STDERR though.

It looks like the server does not understand the command "TYPE binary"
but it does accept "TYPE ascii", and it also looks like it increments
the port with each get(). Here is an excerpt of the log:

Net::FTP=GLOB(0xbfcda4)>>> MDTM
/public_html/employees/pilot_sched.shtml

Net::FTP=GLOB(0xbfcda4)<<< 213 20041217230850
getting /public_html/employees/pilot_sched.shtml as type ascii
Net::FTP=GLOB(0xbfcda4)>>> PORT 68,35,3,131,10,40

Net::FTP=GLOB(0xbfcda4)<<< 200 PORT command successful
Net::FTP=GLOB(0xbfcda4)>>> RETR
/public_html/employees/pilot_sched.shtml

Net::FTP=GLOB(0xbfcda4)<<< 150 Connecting to port 2600
Net::FTP=GLOB(0xbfcda4)<<< 226-File successfully transferred
Net::FTP=GLOB(0xbfcda4)<<< 226 0.000 seconds (measured here), 12.03
Mbytes per second
Net::FTP=GLOB(0xbfcda4)>>> TYPE binary

Net::FTP=GLOB(0xbfcda4)<<< 504-Unknown TYPE: binary
Net::FTP=GLOB(0xbfcda4)<<< 504 TYPE is now ASCII
Net::FTP=GLOB(0xbfcda4)>>> MDTM
/public_html/employees/cgi-bin/CertMan/DB_Certificates

Net::FTP=GLOB(0xbfcda4)<<< 213 20041229054819
getting /public_html/employees/cgi-bin/CertMan/DB_Certificates as
type binary
Net::FTP=GLOB(0xbfcda4)>>> PORT 68,35,3,131,10,41

Net::FTP=GLOB(0xbfcda4)<<< 200 PORT command successful
Net::FTP=GLOB(0xbfcda4)>>> RETR
/public_html/employees/cgi-bin/CertMan/DB_Certificates

Net::FTP=GLOB(0xbfcda4)<<< 150-Connecting to port 2601
Net::FTP=GLOB(0xbfcda4)<<< 150 12.0 kbytes to download
Net::FTP=GLOB(0xbfcda4)<<< 226-File successfully transferred
Net::FTP=GLOB(0xbfcda4)<<< 226 0.000 seconds (measured here), 50.50
Mbytes per second
Net::FTP=GLOB(0xbfcda4)>>> TYPE ascii
Net::FTP=GLOB(0xbfcda4)<<< 200 TYPE is now ASCII
 
B

botfood

FOUND IT...

I dunno if it is standard, but after reviewing the logs closely and
comparing with "manual" fetches with WS_FTP, I noticed that the TYPE
commands accepted by the server are not 'ascii' and 'binary', they are
'A' and 'I'.

When I changed my code to send A or I as I looped through, it makes it
through the entire list. So, it looks like the new Host ftp program is
more picky and doesnt understand 'ascii' and 'binary' and dies.

I am now wondering if the documentation for Net::FTP should clarify
that the accepted settings are 'A' and 'I', or if this is non-standard
and servers *should* accept 'ascii' and 'binary'. ???
 
B

botfood

after a little more testing.... it looks like the better way to code
the type changes is to use the methods ascii() or binary() rather than
the type() method which looks like it isnt even documented inthe
current version of Net::FTP.

so.....

anybody else using the type() method like:
$ftp->type('I');

should switch to
$ftp->binary();

d
 
B

botfood

turns out that the *better* way to switch modes is to use the methods:
ascii() and binary() rather than the type()... in fact the type()
method has been removed from the documentation because a LOT of people
did the same thing I did, and used type('binary') rather than
type('I').
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top