cURL / Mailing Lists / curl-library / Single Mail


Re: libcurl and libssh2

From: Michael Wood <>
Date: Fri, 16 Oct 2009 10:34:20 +0200

2009/10/16 Xu, Qiang (FXSGSC) <>:
>> -----Original Message-----
>> From:
>> [] On Behalf Of Michael Wood
>> I have never used the -Q option myself, but I believe you
>> need something like this:
>> curl ... -Q "rm /path/to/test.txt" sftp://...
> After some tries, I've got it working:
> ==============================================
> qxu@durian(pts/1):~/opensrc/curl-7.19.6/src[121]$ ./curl -v -u qxu:fair123 sftp:// -Q "rm /home/qxu/scan/test.txt"
> Althought it is working, there are some problems.
> 1. It won't work when the path to the file is written as "~/scan/test.txt".

This is not something I can help you with. Maybe a mailing list for
libssh2 would be a better place to ask about it?

> 2. Why the root directory of the sftp server is listed? In my quoted command, there isn't anything related to "ls".

This is because curl is designed to get or put stuff. In my opinion,
the -Q option was added on because it's useful, but curl is not really
designed for doing that sort of thing. So your command above
basically means, please fetch me sftp://, but before you
do that, please send through "rm /home/qxu/scan/test.txt".

So even if you have the -Q, it will still send back the same thing as
if you did not have the -Q there.

> 3. It won't work when I want to remove a folder:
> ==============================================
> qxu@durian(pts/1):~/opensrc/curl-7.19.6/src[126]$ ./curl -v -u qxu:fair123 sftp:// -Q "rm -rf /home/qxu/scan/DOC.XSM"
> I can confirm the folder /home/qxu/scan/DOC.XSM does exist. Can't I use "rm -rf" to remove a folder? What else shall I use?

Those quote commands are not shell commands. They are SFTP protocol
commands (or something like that). So you can probably not use "rm
-rf". But I don't know what you can use instead. You will probably
have to ask the libssh2 people.

Michael Wood <>
List admin:
Received on 2009-10-16