initself has asked for the wisdom of the Perl Monks concerning the following question:

I am attempting to upload a text file to an FTP server using Net::FTP. The resulting text file on the server is an incomplete version of what I am uploading. Uploading an identical file, the file gets 'cut off' at the same place in the file each time.
my $ftp; my $host = "192.168.125.42"; $ftp = Net::FTP->new($host) or die "Cannot connect to host: $@"; $ftp->login("anonymous",'-anonymous@') or die "Cannot login ", $ftp->message; $ftp->ascii; $ftp->put($filename_tran) or die "put failed ", $ftp->message; $ftp->put($filename_occ) or die "put failed ", $ftp->message; $ftp->quit;
The data I am uploading consists of lines that look like this:
RI Anaheim Garden Grove 06-27-2006 UNKNOWN GROSS HOTEL SALES + 100.80M
The last transfered line of this text file ends up looking like this:
RI Anaheim
even though the text file I am uploading has a complete line.

The error is very consistent. I am not sure why other options I have left to try with this module. I do not know how to error check with it. Uploading the file manually results in a successful upload.

Any ideas?

Replies are listed 'Best First'.
Re: Net::FTP - incomplete file upload
by initself (Monk) on Jun 29, 2006 at 03:18 UTC
    $ftp->pasv(); took care of it! Not sure why, but it works.
Re: Net::FTP - incomplete file upload
by muba (Priest) on Jun 29, 2006 at 03:14 UTC
    I don't know much about Net::FTP, but try printing $ftp->message after every ftp operation you perform, just to see what the server says.

    Maybe it yields something useful.
    But then again, maybe not :(
Re: Net::FTP - incomplete file upload
by Anonymous Monk on Jun 29, 2006 at 05:04 UTC
    I thought pasv() was the solution. Turns out I wasn't closing my files! Strange that it was even able to send anything at all!