2009/10/16 Xu, Qiang (FXSGSC) <[email protected]>: >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] 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: > ============================================== > q...@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" [...] > 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://13.198.98.190, 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: > ============================================== > q...@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" [...] > 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 <[email protected]> ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
