cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: libcurl and libssh2

From: Xu, Qiang (FXSGSC) <Qiang.Xu_at_fujixerox.com>
Date: Fri, 16 Oct 2009 15:53:10 +0800

> -----Original Message-----
> From: curl-library-bounces_at_cool.haxx.se
> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Michael Wood
> Sent: Friday, October 16, 2009 3:26 PM
> To: libcurl development
> Subject: Re: libcurl and libssh2
>
> 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://13.198.98.190 -Q "rm /home/qxu/scan/test.txt"
* About to connect() to 13.198.98.190 port 22 (#0)
* Trying 13.198.98.190... connected
* Connected to 13.198.98.190 (13.198.98.190) port 22 (#0)
...
* Initialized password authentication
* Authentication complete
* Sending quote commands
drwxr-xr-x 2 root root 0 Sep 28 09:08 u
drwxr-xr-x 2 root root 0 Oct 16 14:30 packages
drwxr-xr-x 2 root root 4096 Mar 10 2009 selinux
drwxr-xr-x 2 root root 0 Oct 16 11:03 net
drwxr-xr-x 2 root root 0 Sep 28 09:08 misc
drwxr-xr-x 6 root root 4096 May 13 14:06 export
drwxr-xr-x 15 root root 4096 Mar 10 2009 usr
drwx------ 2 root root 16384 Mar 6 2009 lost+found
drwxr-x--- 18 root root 4096 Oct 16 11:06 root
drwxr-xr-x 3 root root 0 Oct 16 11:03 home
drwxr-xr-x 2 root root 0 Sep 28 09:08 projects
-rw-r--r-- 1 root root 0 Mar 7 2009 .autorelabel
drwxr-xr-x 30 root root 4096 Sep 28 09:08 ..
drwxr-xr-x 2 root root 0 Sep 28 09:08 apps
drwxr-xr-x 2 root root 4096 Mar 10 2009 media
dr-xr-xr-x 182 root root 0 Sep 28 09:08 proc
drwxr-xr-x 2 root root 4096 Mar 10 2009 mnt
drwxr-xr-x 3 root root 4096 Mar 10 2009 opt
drwxr-xr-x 4 root root 1024 Apr 15 2009 boot
drwxrwxrwt 12 root root 4096 Oct 16 15:21 tmp
drwxr-xr-x 2 root root 4096 Apr 16 2009 bin
drwxr-xr-x 24 root root 4096 Aug 14 10:13 var
-rw-r--r-- 1 root root 0 Sep 28 09:08 .autofsck
drwxr-xr-x 13 root root 4560 Sep 30 12:41 dev
drwxr-xr-x 2 root root 4096 Mar 10 2009 srv
drwxr-xr-x 104 root root 12288 Oct 16 15:24 etc
drwxr-xr-x 2 root root 12288 Apr 16 2009 sbin
drwxr-xr-x 30 root root 4096 Sep 28 09:08 .
drwxr-xr-x 11 root root 0 Sep 28 09:08 sys
drwxr-xr-x 3 root root 0 Oct 16 15:19 project
drwxr-xr-x 14 root root 4096 Apr 16 2009 lib
drwxr-xr-x 2 root root 0 Sep 28 09:08 tools
* Connection #0 to host 13.198.98.190 left intact
* Closing connection #0
==============================================
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".
2. Why the root directory of the sftp server is listed? In my quoted command, there isn't anything related to "ls".

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://13.198.98.190/ -Q "rm -rf /home/qxu/scan/DOC.XSM"
* About to connect() to 13.198.98.190 port 22 (#0)
* Trying 13.198.98.190... connected
* Connected to 13.198.98.190 (13.198.98.190) port 22 (#0)
...
* Initialized password authentication
* Authentication complete
* Sending quote commands
* rm command failed: No such file or directory
* Connection #0 to host 13.198.98.190 left intact
curl: (21) rm command failed: No such file or directory
* Closing connection #0
==============================================
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?

Any suggestions?

Thanks,
Xu Qiang
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-10-16