LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-02-2009, 04:51 PM   #1
LidoShuffle
LQ Newbie
 
Registered: May 2007
Location: LA
Distribution: Gentoo, OpenSolaris and FreeBSD
Posts: 19

Rep: Reputation: 0
Perl Net::FTP problem


I've got a perl cron job that runs every week and needs to upload output to an ftp server. I've thought about using a shell script, but then found Net::FTP via cpan. I've had great luck with Net::Mail so I figured Net::FTP would work just as well. Unfortunately no. It logs in fine, change directory works, delete file works, but when I try to upload a file via the "put" command, no dice. I've tried the most simple test but it always gives output "226 transfer complete" but the file on the ftp server contains zero bytes. Google searching has uncovered quite a few other people who've run into this, but no solutions.

I've tried two different FTP servers, I've tried specifying the source file name with and without the full path but either way gives the same result (it seems like it could be a source file issue since the file name shows up on the remote server but with zero bytes, like it gets the file name but not the actual file). Anyone here using it successfully? My skills are not up to debugging Net::FTP or the packages it relies on unfortunately.

Here's my code:
Code:
use Net::FTP;

$ftp = Net::FTP->new("ftp.testserver1.com", Debug => 1, Passive => 1)
    or die "Cannot connect to ftp.testserver1.com: $@";

$ftp->login("anon",'1234')                                                                                     
   or die "Cannot login ", $ftp->message;                                                                       

$ftp->binary()
    or die "can\'t go binary ", $ftp->message;

#in case it's already there
$ftp->delete("test.txt");

$ftp->put("/home/me/DataFile.txt",'test.txt')
    or die "put failed ", $ftp->message;
Here's debug output:
Code:
Net::FTP>>> Net::FTP(2.77)
Net::FTP>>>   Exporter(5.58)
Net::FTP>>>   Net::Cmd(2.29)
Net::FTP>>>   IO::Socket::INET(1.29)
Net::FTP>>>     IO::Socket(1.29)
Net::FTP>>>       IO::Handle(1.25)
Net::FTP=GLOB(0x840ab14)<<< 220 Serv-U FTP Server v7.4 ready...
Net::FTP=GLOB(0x840ab14)>>> USER 40300795
Net::FTP=GLOB(0x840ab14)<<< 331 User name okay, need password.
Net::FTP=GLOB(0x840ab14)>>> PASS ....
Net::FTP=GLOB(0x840ab14)<<< 230 User logged in, proceed.
Net::FTP=GLOB(0x840ab14)>>> TYPE A
Net::FTP=GLOB(0x840ab14)<<< 200 Type set to A.
Net::FTP=GLOB(0x840ab14)>>> DELE test.txt
Net::FTP=GLOB(0x840ab14)<<< 250 DELE command successful.
Net::FTP=GLOB(0x840ab14)>>> PASV
Net::FTP=GLOB(0x840ab14)<<< 227 Entering Passive Mode (138,108,54,156,6,102)
Net::FTP=GLOB(0x840ab14)>>> STOR test.txt
Net::FTP=GLOB(0x840ab14)<<< 150 Opening ASCII mode data connection for test.txt.
Net::FTP=GLOB(0x840ab14)<<< 226 Transfer complete. 0 bytes transferred. 0.00 KB/sec.
Net::FTP=GLOB(0x840ab14)>>> QUIT
Net::FTP=GLOB(0x840ab14)<<< 221 Goodbye, closing session.
 
Old 06-02-2009, 05:45 PM   #2
BubbaJoe
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
Try running it with Debug set to 3 and see what you get. You may not have permissions to write to the directory or is using the wrong port.
 
Old 06-02-2009, 05:54 PM   #3
LidoShuffle
LQ Newbie
 
Registered: May 2007
Location: LA
Distribution: Gentoo, OpenSolaris and FreeBSD
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks for the reply. Setting debug to 3 gives the same output (the docs don't indicate that there are varying debug levels in either Net::FTP or the Net::Cmd package which it uses). It isn't a permissions issue because I'm able to write to both ftp servers using an ftp client on my machine. It can't be the wrong port because it's connecting fine and doing everything ok except sending a file.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Net::FTP - LIST Causes Connection Hang taylor_venable Programming 0 01-05-2006 03:59 PM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 06:57 PM
perl and Net::FTP question Tomasfuego Programming 0 12-17-2003 08:13 AM
perl, Net::Ftp, and Novell file modification time neo77777 Programming 0 01-30-2003 09:41 PM
perl NET::FTP binary mode lackluster Programming 5 07-18-2002 06:30 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration