wxman1
asked on
PERL and ftp
Hi All,
I am trying to write a script that will ftp files from a Linux PC, to a Web Server. I wrote a PERL script, and when I execute it, first of all, it takes quite a while to send a 1 kb file, and then, when I check the destination directory after words, the file is listed there but is 0 kb, and is completely empty. I've been trying to send a txt file just to work the bugs out, but I am completely stumped. I've tried binary mode and Ascii (I'm really not sure when to use either of them) and still the same results. Here is the script I wrote:
#!/usr/bin/perl
use CGI;
use Net::FTP;
$LOGIC="xxx.xxx.xxx.xxx"; # destination i.p. address actual address is in my script
$file="brian.txt"; #file I want to transfer
$ftp = Net::FTP->new($LOGIC, Debug => 0);
$ftp->login("username","pa ssword"); #actual username and password is in my script
$ftp->put($file);
$ftp->quit;
exit();
I am trying to write a script that will ftp files from a Linux PC, to a Web Server. I wrote a PERL script, and when I execute it, first of all, it takes quite a while to send a 1 kb file, and then, when I check the destination directory after words, the file is listed there but is 0 kb, and is completely empty. I've been trying to send a txt file just to work the bugs out, but I am completely stumped. I've tried binary mode and Ascii (I'm really not sure when to use either of them) and still the same results. Here is the script I wrote:
#!/usr/bin/perl
use CGI;
use Net::FTP;
$LOGIC="xxx.xxx.xxx.xxx"; # destination i.p. address actual address is in my script
$file="brian.txt"; #file I want to transfer
$ftp = Net::FTP->new($LOGIC, Debug => 0);
$ftp->login("username","pa
$ftp->put($file);
$ftp->quit;
exit();
I think that it might be due to the put could not find the file. It is better to use full path in $file such as
$file = "/my/path/to/brain.txt";
$file = "/my/path/to/brain.txt";
ASKER
Okay,
After turning on the debugging, this is what came back:
Net::FTP>>> Net::FTP(2.72)
Net::FTP>>> Exporter(5.57)
Net::FTP>>> Net::Cmd(2.24)
Net::FTP>>> IO::Socket::INET(1.27)
Net::FTP>>> IO::Socket(1.28)
Net::FTP>>> IO::Handle(1.23)
Net::FTP=GLOB(0x9e2570)<<< 220 logic-web-b FTP Server (vftpd 1.31) ready.
Net::FTP=GLOB(0x9e2570)>>> user username
Net::FTP=GLOB(0x9e2570)<<< 331 Password required for username.
Net::FTP=GLOB(0x9e2570)>>> PASS ....
Net::FTP=GLOB(0x9e2570)<<< 230 User username logged in.
Net::FTP=GLOB(0x9e2570)>>> ALLO 11
Net::FTP=GLOB(0x9e2570)<<< 200 ALLO command ignored.
Net::FTP=GLOB(0x9e2570)>>> PORT 10,0,2,55,210,30
Net::FTP=GLOB(0x9e2570)<<< 200 PORT command successful.
Net::FTP=GLOB(0x9e2570)>>> STOR brian.txt
Net::FTP=GLOB(0x9e2570)<<< 150 Opening ASCII mode data connection for brian.txt
putOpening ASCII mode data connection for brian.txt
Thats what came up on the screen. Any suggestions?
After turning on the debugging, this is what came back:
Net::FTP>>> Net::FTP(2.72)
Net::FTP>>> Exporter(5.57)
Net::FTP>>> Net::Cmd(2.24)
Net::FTP>>> IO::Socket::INET(1.27)
Net::FTP>>> IO::Socket(1.28)
Net::FTP>>> IO::Handle(1.23)
Net::FTP=GLOB(0x9e2570)<<<
Net::FTP=GLOB(0x9e2570)>>>
Net::FTP=GLOB(0x9e2570)<<<
Net::FTP=GLOB(0x9e2570)>>>
Net::FTP=GLOB(0x9e2570)<<<
Net::FTP=GLOB(0x9e2570)>>>
Net::FTP=GLOB(0x9e2570)<<<
Net::FTP=GLOB(0x9e2570)>>>
Net::FTP=GLOB(0x9e2570)<<<
Net::FTP=GLOB(0x9e2570)>>>
Net::FTP=GLOB(0x9e2570)<<<
putOpening ASCII mode data connection for brian.txt
Thats what came up on the screen. Any suggestions?
ASKER
geotiger
I added the full path, still having the same problem though
I added the full path, still having the same problem though
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Passive Mode! I completely forgot! That did the trick thanks!
$ftp = Net::FTP->new($LOGIC, Debug => 1);
$ftp->login("username","pa
$ftp->put($file) or die 'put', $ftp->message;
$ftp->quit;