Net::FTP error on put: Bad command sequence

M

mnagaraj

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.
 
J

J. Gleixner

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?
 
M

mnagaraj

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.
 
L

l v

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top