> -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Peter Stuge > Sent: Monday, October 19, 2009 10:01 AM > To: [email protected] > Subject: Re: quote commands in sftp > > Now I understand. Thanks! > > This example makes everything clear. It is very important to > show examples of what you are doing when there is a problem. > > Also remember that this mailing list is for libssh2, so in > order to reach the curl experts it is better to post > questions about curl to the curl mailing list. Originally, I posted the question to curl mailist. Someone there recommended me seek help here. :-) > [...] > There is no such thing as sending a quoted command via SFTP. > > SFTP is, as described in the draft and in the curl > documentation, a binary, packet based, protocol. It doesn't > used text based commands and responses like FTP. > > curl uses libssh2 and transforms the text command above into > an SFTP request packet where the rmdir command is encoded as > the SSH_FXP_RMDIR request id and the directory you specify is > encoded as a string following it in the packet.
Got it, thanks. By the way, my curl executable is a statically built one, coz the inborn curl with the linux box is outdated, and doesn't support sftp. And, I am not the SA of the linux machine. Someone in curl mailist suggested me build a static curl command. Yes, it works. But when I invoke 'man curl', it is still the system one, not the manual for my static curl. > > it is probably the server that executes the command > > The SFTP server parses the packet, and will normally execute the > unlink() system call on the specified path. > > > > (and fails). > > Yes. Only empty directories can be removed. > > If you want to delete a directory including all contents, you > must manually fetch the contents of that directory (using the SFTP > protocol) and recursively delete every file in every subdirectory. > > If you can log in to the system and execute commands then you > can use that method instead of SFTP, and execute rm -rf. That > is not supported in curl, and I think that is wise. Why is it wise? Isn't it more convenient to have this "rm -rf" command supported in curl? Just curious about it. > > Now I am working with sftp server. > > Which SFTP server? The one in OpenSSH? Actually, I only know the server supports sftp transfer. How to identify the sftp server's type? > > So is http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13 > > enough for me? :-) > > If you are working with the OpenSSH SFTP server then it is > better to use the documentation that applies to it. > > > But the answer to deleting files recursively can not be found > in any draft and it has nothing to do with quotes. There are > only two solutions as mentioned above; > > 1. Write your own SFTP client (e.g. using libssh2) which > recurses through all subdirectories and deletes everything > before removing the top level directory. > > or > > 2. Execute rm -rf on the system, via SSH or some other way. By the way, I am tasked to implement SFTP transfer in our printers. I have two options. One is to implement it directly with libssh2, the other is to implement it via libcurl. In my eyes, the second approach is simpler. What's your opinion, Peter? Besides libcurl, is there any other application which is using libssh2 to implement SFTP transfer? Thanks a lot for your detailed explanation, Xu Qiang _______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
