![]() |
Net::FTP error on put: Bad command sequence
This is the code producing the error:
<---------------snip-----------> use strict; use warnings; use Net::FTP; my $firm_user = 'string1'; my $firm_pass = "string2"; my $firm_dir = "string3"; my $outfile = "string4"; #Open a socks FTP connection my $ftp = Net::FTP->new('socks'); $ftp->login($firm_user, $firm_pass) or die print("ERROR! Unable to connect to the FTP server: ", $ftp->message); $ftp->ascii(); $ftp->cwd($firm_dir) or die print("ERROR! Unable to 'cd' to $firm_dir directory: ", $ftp->message); $ftp->put($outfile) or die print("ERROR! Unable to ftp the file at this time: ", $ftp->message); $ftp->quit; <--------end snip--------> I tried, ls, pwd, etc and all these work. I tried the FTP from the shell and it works just fine. Any clues as to what might cause this error. BTW this program did work in the past. I am clueless as to the source of the error! Thanks, -mouli. |
Re: Net::FTP error on put: Bad command sequence
mnagaraj@gmail.com wrote:
> This is the code producing the error: > <---------------snip-----------> > use strict; > use warnings; > use Net::FTP; > > my $firm_user = 'string1'; > my $firm_pass = "string2"; > my $firm_dir = "string3"; > my $outfile = "string4"; > > #Open a socks FTP connection > my $ftp = Net::FTP->new('socks'); > > $ftp->login($firm_user, $firm_pass) > or die print("ERROR! Unable to connect to the FTP server: ", > $ftp->message); > > $ftp->ascii(); > > $ftp->cwd($firm_dir) > or die print("ERROR! Unable to 'cd' to $firm_dir directory: ", > $ftp->message); > > $ftp->put($outfile) > or die print("ERROR! Unable to ftp the file at this time: ", > $ftp->message); > > $ftp->quit; > <--------end snip--------> > > I tried, ls, pwd, etc and all these work. I tried the FTP from the > shell and it works just fine. Any clues as to what might cause this > error. > > BTW this program did work in the past. I am clueless as to the source > of the error! First, the die command works just fine, no need to die print: $ftp->cwd($firm_dir) or die "ERROR! Unable to 'cd' to $firm_dir directory: " . $ftp->message; perldoc -f die Second, add Debug => 1, to the new to see if that helps. Third, does $outfile exist? |
Re: Net::FTP error on put: Bad command sequence
J.Gleixner,
I included 1 & 2 as recommended by you. On 3, yes $outfile does exist. If it doesn't, I get a different error (local file not found error). Here is the result of the debug trace: Outfile: a Net::FTP>>> Net::FTP(2.75) Net::FTP>>> Exporter(5.562) Net::FTP>>> Net::Cmd(2.26) Net::FTP>>> IO::Socket::INET(1.25) Net::FTP>>> IO::Socket(1.26) Net::FTP>>> IO::Handle(1.21) Net::FTP=GLOB(0x31d28)<<< 220 Secure Gateway FTP server Net::FTP=GLOB(0x31d28)>>> user anonymous@**.com Net::FTP=GLOB(0x31d28)<<< 331-Connected to **.com Net::FTP=GLOB(0x31d28)<<< 331-(vsFTPd 1.2.1) Net::FTP=GLOB(0x31d28)<<< 331 Please specify the password. Net::FTP=GLOB(0x31d28)>>> PASS .... Net::FTP=GLOB(0x31d28)<<< 230 Login successful. Net::FTP=GLOB(0x31d28)>>> TYPE A Net::FTP=GLOB(0x31d28)<<< 200 Switching to ASCII mode. Net::FTP=GLOB(0x31d28)>>> CWD pub/incoming Net::FTP=GLOB(0x31d28)<<< 250 Directory successfully changed. Net::FTP=GLOB(0x31d28)>>> PORT 69,52,99,54,135,100 Net::FTP=GLOB(0x31d28)<<< 200 PORT command successful. Consider using PASV. Net::FTP=GLOB(0x31d28)>>> NLST Net::FTP=GLOB(0x31d28)<<< 150 Here comes the directory listing. Net::FTP=GLOB(0x31d28)<<< 226 Directory send OK. Net::FTP=GLOB(0x31d28)>>> ALLO 6 Net::FTP=GLOB(0x31d28)<<< 202 ALLO command ignored. Net::FTP=GLOB(0x31d28)>>> PORT 69,52,99,54,135,101 Net::FTP=GLOB(0x31d28)<<< 530 Bad command sequence ERROR! Unable to ftp the file at this time: Bad command sequence Noting the recommendation for Passive mode, I tried that with the same result. Thanks for your help. -mouli. |
Re: Net::FTP error on put: Bad command sequence
mnagaraj@gmail.com wrote:
> J.Gleixner, > > I included 1 & 2 as recommended by you. > On 3, yes $outfile does exist. If it doesn't, I get a different error > (local file not found error). > > Here is the result of the debug trace: > > Outfile: a > Net::FTP>>> Net::FTP(2.75) > Net::FTP>>> Exporter(5.562) > Net::FTP>>> Net::Cmd(2.26) > Net::FTP>>> IO::Socket::INET(1.25) > Net::FTP>>> IO::Socket(1.26) > Net::FTP>>> IO::Handle(1.21) > Net::FTP=GLOB(0x31d28)<<< 220 Secure Gateway FTP server > Net::FTP=GLOB(0x31d28)>>> user anonymous@**.com > Net::FTP=GLOB(0x31d28)<<< 331-Connected to **.com > Net::FTP=GLOB(0x31d28)<<< 331-(vsFTPd 1.2.1) > Net::FTP=GLOB(0x31d28)<<< 331 Please specify the password. > Net::FTP=GLOB(0x31d28)>>> PASS .... > Net::FTP=GLOB(0x31d28)<<< 230 Login successful. > Net::FTP=GLOB(0x31d28)>>> TYPE A > Net::FTP=GLOB(0x31d28)<<< 200 Switching to ASCII mode. > Net::FTP=GLOB(0x31d28)>>> CWD pub/incoming > Net::FTP=GLOB(0x31d28)<<< 250 Directory successfully changed. > Net::FTP=GLOB(0x31d28)>>> PORT 69,52,99,54,135,100 > Net::FTP=GLOB(0x31d28)<<< 200 PORT command successful. Consider using > PASV. > Net::FTP=GLOB(0x31d28)>>> NLST > Net::FTP=GLOB(0x31d28)<<< 150 Here comes the directory listing. > Net::FTP=GLOB(0x31d28)<<< 226 Directory send OK. > Net::FTP=GLOB(0x31d28)>>> ALLO 6 > Net::FTP=GLOB(0x31d28)<<< 202 ALLO command ignored. > Net::FTP=GLOB(0x31d28)>>> PORT 69,52,99,54,135,101 > Net::FTP=GLOB(0x31d28)<<< 530 Bad command sequence > ERROR! Unable to ftp the file at this time: Bad command sequence > > Noting the recommendation for Passive mode, I tried that with the same > result. > > Thanks for your help. > > -mouli. > I'm betting that the file name in $outfile is causing the problem. Meaning it contains some characters which the ftp server does not like. What is the exact contents of $outfile which cause the error? What is in the ftp logs? Len |
| All times are GMT. The time now is 08:41 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.