sharpmail
asked on
Perl Net FTP file only half transfers then ends?
Hi,
Im trying to FTP a zip of about 100MB, it part transfers (aprox 1 third to half, diffrent each time.) then bombs out with a script error :S I dont see any problems, anyone help?
Script and error log below
use Net::FTP;
$ftpsite = "wol.XXXXXXX.net";
$ftp = Net::FTP->new("$ftpsite", Debug => 1)
or die "Can not connect to FTP site", $ftp->message;
$ftp->login("XXXXXXX",'XXX XXXX')
or die "Cannot login", $ftp->message;
$ftp->cwd("/site_backup")
or die "Cannot change working directory to /site_backup", $ftp->message;
$ftp->put ("/home/default/sharpmail. co.uk/user /htdocs/ba ckup_tmp/h tdocs.zip" )
or die "put failed", $ftp->message;
$ftp->quit;
print "Done!";
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> Net::FTP(2.75)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> Exporter(5.58)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> Net::Cmd(2.26)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> IO::Socket::INET(1.27)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> IO::Socket(1.28)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> IO::Handle(1.24)
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 220 LINKSTATION FTP server ready
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>> > user ftpbackup\r
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 331 Password required for ftpbackup.
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>> > PASS ....
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 230 User ftpbackup logged in.
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>> > CWD /site_backup\r
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 250 CWD command successful.
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>> > ALLO 105837300\r
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 202 No storage allocation necessary.
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>> > PASV\r
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 227 Entering Passive Mode (84,69,111,168,4,127).
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>> > STOR htdocs.zip\r
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 150 Opening BINARY mode data connection for htdocs.zip
[Sun Apr 30 20:06:14 2006] [error] [client 84.69.111.168] Premature end of script headers: ftp.cgi
[Sun Apr 30 20:09:16 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 226 Transfer complete.
[Sun Apr 30 20:09:16 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>> > QUIT\r
[Sun Apr 30 20:09:16 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<< < 221 Goodbye.
Im trying to FTP a zip of about 100MB, it part transfers (aprox 1 third to half, diffrent each time.) then bombs out with a script error :S I dont see any problems, anyone help?
Script and error log below
use Net::FTP;
$ftpsite = "wol.XXXXXXX.net";
$ftp = Net::FTP->new("$ftpsite", Debug => 1)
or die "Can not connect to FTP site", $ftp->message;
$ftp->login("XXXXXXX",'XXX
or die "Cannot login", $ftp->message;
$ftp->cwd("/site_backup")
or die "Cannot change working directory to /site_backup", $ftp->message;
$ftp->put ("/home/default/sharpmail.
or die "put failed", $ftp->message;
$ftp->quit;
print "Done!";
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> Net::FTP(2.75)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> Exporter(5.58)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> Net::Cmd(2.26)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> IO::Socket::INET(1.27)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> IO::Socket(1.28)
[Sun Apr 30 20:01:09 2006] [error] [client 84.69.111.168] Net::FTP>>> IO::Handle(1.24)
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>>
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>>
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>>
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>>
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>>
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>>
[Sun Apr 30 20:01:14 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:06:14 2006] [error] [client 84.69.111.168] Premature end of script headers: ftp.cgi
[Sun Apr 30 20:09:16 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
[Sun Apr 30 20:09:16 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)>>
[Sun Apr 30 20:09:16 2006] [error] [client 84.69.111.168] Net::FTP=GLOB(0x9ab498c)<<
Could well be, what is the exact script wrror your are getting? Also default timeout is 120 seconds, so maybe try
$ftp = Net::FTP->new("$ftpsite", Debug => 1, Timeout => 600)
$ftp = Net::FTP->new("$ftpsite", Debug => 1, Timeout => 600)
ASKER
is this not the connection timeout? a connection is made and file partly transfered. the exact error is simply error 500 and the log shows (as above) [Sun Apr 30 20:06:14 2006] [error] [client 84.69.111.168] Premature end of script headers: ftp.cgi
Yes you are right, the timeout wont help you here. 500 is a syntax error. You could try connecting in passive mode to help get around this. But the error message seems to suggest you may already be in passive mode.
At this stage, I would try the same transfer manually with your FTP client. It will be easy to tinker with the setting from within this environment.
At this stage, I would try the same transfer manually with your FTP client. It will be easy to tinker with the setting from within this environment.
ASKER
it is in passive, they are not errors in the log, i ran in debug mode, thats why they are there. the only error as such is the :
[Sun Apr 30 20:06:14 2006] [error] [client 84.69.111.168] Premature end of script headers: ftp.cgi
but this does not happen untill the script has been running for a little while and then terminated for some reason. Could the script be getting terminated by say apache? is there a way to stop this?
[Sun Apr 30 20:06:14 2006] [error] [client 84.69.111.168] Premature end of script headers: ftp.cgi
but this does not happen untill the script has been running for a little while and then terminated for some reason. Could the script be getting terminated by say apache? is there a way to stop this?
So you are running this script as as CGI script? That makes a big difference when it comes to timeouts. How long does it normally take to transfer the file?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have solved it now, NET::FTP transfers as ASCII by default and it should be binary, made the transfer binary and it works fine.
$ftp->binary();
before put command.
$ftp->binary();
before put command.
that's odd becuase I checked your error log and it reporterd binary mode. Anyway, glad it's working
----
Opening BINARY mode data connection for htdocs.zip
----
Opening BINARY mode data connection for htdocs.zip
ASKER
thats a good point :s but when i take " $ftp->binary(); " out it does not work - verry strange
ASKER
have the points anyway!
That's bizare!
I don't see how having
$ftp->binary();
would solve the symptoms you had. Doesn't make sense (to me at least)
I don't see how having
$ftp->binary();
would solve the symptoms you had. Doesn't make sense (to me at least)
Thanks for points, but yes am also still confused. Why would a text mode transfer only fail one third of the way through. Anyway I guess as the data is binary, that was the source of the problem
ASKER
well it seems it did not fail half way as such, its just the zip was corrupted when it reach the destination (windows) adding binary, for what ever reason means its working :s
ASKER