cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: SFTP - How to delete a file

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 30 Aug 2007 12:58:20 -0700

On Thu, Aug 30, 2007 at 02:13:00PM -0500, Mathew Simon wrote:
> You are incredible! I answered every question you asked.

Thank you for the compliment (I'm giving the benefit of the doubt)!
It has taken several requests to finally get some of that information,
though: it took *13* messages between my asking you to try running
the curl command line and you finally posting that command line, for
example. I'm not getting paid for this--if it gets too frustrating
(and this long thread is trying it), I won't be motivated to try.

> The Curl command line is given below. I am manually typing it in my
> email since there is no mail facilities on the testing machine.

That's not as good as cutting and pasting--it's too easy to transcribe
something incorrectly.

> The following two line displays the root directory list as a console
> output (stdout or stderr). The only difference is the slash at the end
> and both are producing the directory listing.
> curl sftp://xxx.xxx.com --user xxx:pass
> curl sftp://xxx.xxx.com/ --user xxx:pass
>
> The following line do not produce any outputs, no error also.
> curl sftp://xxx.xxx.com/ReceiveFiles --user xxx:pass

Ok, now that I've seen your command line, I can suggest adding -v to get
verbose debug output. You'll see the verbose SSH error string that way,
if there is one, plus some debug messages.

> The following gives error. Curl: (21) Syntax error in SFTP command.
> Supply parameters(s).
> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> pwd
> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> 'pwd'

These two are known to be broken--no surprises there.

> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> 'rm'

'rm' taken an argument. This is also expected to return an error.

> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> 'heaven'
> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> heaven

'heaven' isn't a sftp command. an error here is also expected.

> The following commands gives two errors.
> curl: (21) Syntax error in SFTP command. Supply parameters(s).
> curl: (3) <url> malformed
>
> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> 'rm /ReceiveFiles/test2.txt'

I suspect the problem here is with Windows not supporting the single quote.
Try replacing the single quotes with double quotes.

> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> rm /ReceiveFiles/test2.txt

This isn't going to work at all, because the --quote option is going to
look at the "rm" command alone, and the path name is going to be treated
as a URL to download.

> The following commands gives two errors.
> curl: (21) Syntax error in SFTP command. Supply parameters(s).
> curl: (6) Could not resolve hots: 'test2.txt'; no data record of
> requested type
> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> rm 'test2.txt'

The same problem here.

> curl sftp://xxx.xxx.com/ReceiveFiles/test2.txt --user xxx:pass --quote
> 'rm test2.txt'

This is likely the single quote problem.

> I hope that this much is sufficient.

If the suggestions above solve your problem, then it has been.

If you are still having problem with your application, please post the code.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-08-30