cURL / Mailing Lists / curl-users / Single Mail

curl-users

Noob question: quoted DELE command returns 19 on success

From: G. T. Stresen-Reuter <tedmasterweb_at_gmail.com>
Date: Fri, 9 Jan 2009 14:55:28 +0000

Hi,

I'm new to curl, so please go easy on me...

I'm trying to use curl from within a bash script to delete a file via
FTP. Here is a sample of the command I am using

curl -v -u user:pass ftp://domain.com/httpdocs/samples/test.txt -Q
"dele httpdocs/samples/test.txt" --ftp-method nocwd

I was hoping the return value of the command would tell me whether or
not the quoted DELE command succeeded or not. A return value of 0
would mean success while other values would mean some kind of error.

However, once the command completes (successfully), curl appears to
try listing the file (or the directory) twice before giving up and
returning error 19 (FTP couldn't download/access the given file, the
RETR (or similar) command failed.) rather than returning 0.

Here is a verbose transcript of the command:
###################################

~$ curl -v -u user:pass ftp://domain.com/httpdocs/samples/test.txt -Q
"dele httpdocs/samples/test.txt" --ftp-method nocwd --show-error
* About to connect() to domain.com port 21 (#0)
* Trying 204.1.1.1... connected
* Connected to domain.com (204.1.1.1) port 21 (#0)
< 220 ProFTPD 1.3.1 Server (ProFTPD) [204.1.1.1]
> USER user
< 331 Password required for user
> PASS pass
< 230 User user logged in
> PWD
< 257 "/" is the current directory
* Entry path is '/'
> dele httpdocs/samples/test.txt
< 250 DELE command successful
> EPSV
* Connect data stream passively
< 229 Entering Extended Passive Mode (|||34329|)
* Trying 204.1.1.1... connected
* Connecting to 204.1.1.1 (204.1.1.1) port 34329
> TYPE I
< 200 Type set to I
> SIZE httpdocs/samples/test.txt
< 550 httpdocs/samples/test.txt: No such file or directory
> RETR httpdocs/samples/test.txt
< 550 httpdocs/samples/test.txt: No such file or directory
* RETR response: 550
* Connection #0 to host domain.com left intact
> QUIT
< 221 Goodbye.
* Closing connection #0

##################################

Is this normal behavior? Is this an issue with the FTP server (forcing
the list somehow)? Is there anyway I can just get the return value of
DELE command (short of parsing the verbose output)?

I tried appending --disable-epsv to no avail (but that doesn't seem
like it should make a difference as it seems to affect the
communication method rather than the behavior).

BTW, it has crossed my mind that return code 19 is, in a way, a
confirmation that the file has been deleted since other return codes
(such as 21) would indicate the file was either not there in the first
place or could not be read by the FTP user.

Thanks in advance.

Ted Stresen-Reuter
http://tedmasterweb.com

PS: How high is the scripted "recursive delete" mountain? Is it even
worth trying to climb or should I be looking for an open source
solution somewhere?

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-01-09