Net::FTP error on put: Bad command sequence

Discussion in 'Perl Misc' started by mnagaraj@gmail.com, Apr 18, 2006.

  1. Guest

    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.
    , Apr 18, 2006
    #1
    1. Advertising

  2. J. Gleixner Guest

    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?
    J. Gleixner, Apr 19, 2006
    #2
    1. Advertising

  3. Guest

    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.
    , Apr 19, 2006
    #3
  4. l v Guest

    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
    l v, Apr 20, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    5,598
  2. rantingrick
    Replies:
    44
    Views:
    1,173
    Peter Pearson
    Jul 13, 2010
  3. Jeff Miller
    Replies:
    0
    Views:
    469
    Jeff Miller
    Mar 26, 2009
  4. D. Buck
    Replies:
    2
    Views:
    463
    D. Buck
    Jun 29, 2004
  5. Asaf Sinai
    Replies:
    1
    Views:
    232
    Chris Davies
    Jul 4, 2006
Loading...

Share This Page