Todd Chester has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

Over on

http://search.cpan.org/~shay/libnet-3.10/lib/Net/FTP.pm

The entry for "quot" says:

quot (CMD ,ARGS)
Send a command, that Net::FTP does not directly support, to the remote server and wait for a response.
Returns most significant digit of the response code.

I want to delete a file, which is the correct syntax (neither work, return code is a 5)

my $RetCode = $ftp->quot ( "delete", "$Target" );
my $RetCode = $ftp->quot ( "delete $Target" );

What am I doing wrong?

Many thanks,
-T

Replies are listed 'Best First'.
Re: Need syntax help for Net::FTP::Quot
by NetWallah (Canon) on Feb 10, 2017 at 07:19 UTC
    According to Wikipedia, the FTP copmmand to delete is DELE.

    Some FTP servers support "DEL" and "delete". Try DELE.

    SOme FTP servers are fussy about funny characters in the file name. Hopefully, your $Target is simple.

            ...it is unhealthy to remain near things that are in the process of blowing up.     man page for WARP, by Larry Wall

      Thank you!

      I was thinking in terms of what I have seen in ftp clients and not what was in the RFC.

      Now to figure out if it is ( "DELE", "$Target" ) or ( "DELE $Target" ), which shouldn't be too hard
        The RFC says:

        DELE <SP> <pathname> <CRLF>

        And I have no idea what <SP> means. I hope it means "space"
Re: Need syntax help for Net::FTP::Quot
by Todd Chester (Scribe) on Feb 14, 2017 at 05:43 UTC
    Hi All,

    In case it helps someone else, this is how to delete with Net::FTP::quot

    The RFC:
    DELE <SP> <pathname> <CRLF>
    if ( $ftp->quot ( "DELE", "$Target" ) ) { print "File $Target was directly deleted by ftp->quot\n"; } else { print "File $Target failed to delete with ftp->quot\n"; }
    -T