Hi, all: I want to know the default path after the user logs in through SFTP protocol. Therefore, I did the following: ====================================== q...@durian(pts/2):~/opensrc/curl-7.19.6/src[112]$ ./curl -u qxu:fair123 sftp://13.198.98.190/~/scan/ --quote "pwd" --libcurl sftp_pwd_test.c drwxrwxr-x 3 qxu XOG_cc 9216 Nov 6 18:30 . drwxrwxr-x 20 qxu XOG_cc 3072 Nov 10 16:28 .. drwxrwxr-x 2 qxu XOG_cc 7168 Nov 5 16:14 sxc -rwxr-xr-x 1 qxu XOG_cc 560 Nov 5 16:13 ren3.pl -rwxr-xr-x 1 qxu XOG_cc 131 Nov 2 11:56 ren1.sh -rw-r--r-- 1 qxu XOG_cc 2106 Nov 6 18:29 test.txt -rwxr-xr-x 1 qxu XOG_cc 88 Nov 5 16:15 ren2.sh -rw-r--r-- 1 qxu XOG_cc 2106 Nov 6 18:30 test1.txt ====================================== The command seems to be successful, but I can only see the destination directory's content listing. How can I retrieve the result of the quoted command "pwd"? By the way, from the generated source code, I couldn't find a place where the command "pwd" is set into some "CURLOPT_XXX". How is the command reflected in the source?
Looking forward to help, Xu Qiang
/********* Sample code generated by the curl command line tool ********** * Lines with [REMARK] below might need to be modified to make this code * usable. Add error code checking where appropriate. * Compile this with a suitable header include path. Then link with * libcurl. * If you use any *_LARGE options, make sure your compiler figure * out the correct size for the curl_off_t variable. * Read the details for all curl_easy_setopt() options online on: * http://curlm.haxx.se/libcurl/c/curl_easy_setopt.html ************************************************************************/ #define _FILE_OFFSET_BITS 64 /* for pre libcurl 7.19.0 curl_off_t magic */ #include <curl/curl.h> int main(int argc, char *argv[]) { CURLcode ret; CURL *hnd = curl_easy_init(); /* curl_easy_setopt(hnd, CURLOPT_WRITEDATA, 0xbf82cfb8); [REMARK] */ /* curl_easy_setopt(hnd, CURLOPT_WRITEFUNCTION, 0x80501b0); [REMARK] */ /* curl_easy_setopt(hnd, CURLOPT_READDATA, 0xbf82cff8); [REMARK] */ /* curl_easy_setopt(hnd, CURLOPT_READFUNCTION, 0x8050140); [REMARK] */ /* curl_easy_setopt(hnd, CURLOPT_SEEKDATA, 0xbf82cff8); [REMARK] */ /* curl_easy_setopt(hnd, CURLOPT_SEEKFUNCTION, 0x8050100); [REMARK] */ curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)-1); curl_easy_setopt(hnd, CURLOPT_URL, "sftp://13.198.98.190/~/scan/"); curl_easy_setopt(hnd, CURLOPT_PROXY, NULL); curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(hnd, CURLOPT_HEADER, 0); curl_easy_setopt(hnd, CURLOPT_FAILONERROR, 0); curl_easy_setopt(hnd, CURLOPT_UPLOAD, 0); curl_easy_setopt(hnd, CURLOPT_DIRLISTONLY, 0); curl_easy_setopt(hnd, CURLOPT_APPEND, 0); curl_easy_setopt(hnd, CURLOPT_NETRC, 0); curl_easy_setopt(hnd, CURLOPT_FOLLOWLOCATION, 0); curl_easy_setopt(hnd, CURLOPT_UNRESTRICTED_AUTH, 0); curl_easy_setopt(hnd, CURLOPT_TRANSFERTEXT, 0); curl_easy_setopt(hnd, CURLOPT_USERPWD, "qxu:fair123"); curl_easy_setopt(hnd, CURLOPT_PROXYUSERPWD, NULL); curl_easy_setopt(hnd, CURLOPT_NOPROXY, NULL); curl_easy_setopt(hnd, CURLOPT_RANGE, NULL); /* curl_easy_setopt(hnd, CURLOPT_ERRORBUFFER, 0xbf82ce3c); [REMARK] */ curl_easy_setopt(hnd, CURLOPT_TIMEOUT, 0); curl_easy_setopt(hnd, CURLOPT_REFERER, NULL); curl_easy_setopt(hnd, CURLOPT_AUTOREFERER, 0); curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.19.6 (i686-pc-linux-gnu) libcurl/7.19.6 OpenSSL/0.9.8b zlib/1.2.3 libssh2/1.2"); curl_easy_setopt(hnd, CURLOPT_FTPPORT, NULL); curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_LIMIT, 0); curl_easy_setopt(hnd, CURLOPT_LOW_SPEED_TIME, 0); curl_easy_setopt(hnd, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t)0); curl_easy_setopt(hnd, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t)0); curl_easy_setopt(hnd, CURLOPT_RESUME_FROM_LARGE, (curl_off_t)0); curl_easy_setopt(hnd, CURLOPT_COOKIE, NULL); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, NULL); curl_easy_setopt(hnd, CURLOPT_SSLCERT, NULL); curl_easy_setopt(hnd, CURLOPT_SSLCERTTYPE, NULL); curl_easy_setopt(hnd, CURLOPT_SSLKEY, NULL); curl_easy_setopt(hnd, CURLOPT_SSLKEYTYPE, NULL); curl_easy_setopt(hnd, CURLOPT_KEYPASSWD, NULL); curl_easy_setopt(hnd, CURLOPT_SSH_PRIVATE_KEYFILE, NULL); curl_easy_setopt(hnd, CURLOPT_SSH_PUBLIC_KEYFILE, NULL); curl_easy_setopt(hnd, CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, NULL); curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYHOST, 2); curl_easy_setopt(hnd, CURLOPT_SSH_KNOWNHOSTS, "/home/qxu/.ssh/known_hosts"); curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50); curl_easy_setopt(hnd, CURLOPT_CRLF, 0); /* curl_easy_setopt(hnd, CURLOPT_QUOTE, 0x84c2d30); [REMARK] */ curl_easy_setopt(hnd, CURLOPT_POSTQUOTE, NULL); curl_easy_setopt(hnd, CURLOPT_PREQUOTE, NULL); curl_easy_setopt(hnd, CURLOPT_WRITEHEADER, NULL); curl_easy_setopt(hnd, CURLOPT_COOKIEFILE, NULL); curl_easy_setopt(hnd, CURLOPT_COOKIESESSION, 0); curl_easy_setopt(hnd, CURLOPT_SSLVERSION, 0); curl_easy_setopt(hnd, CURLOPT_TIMECONDITION, 0); curl_easy_setopt(hnd, CURLOPT_TIMEVALUE, 0); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, NULL); /* curl_easy_setopt(hnd, CURLOPT_STDERR, 0x645560); [REMARK] */ curl_easy_setopt(hnd, CURLOPT_HTTPPROXYTUNNEL, 0); curl_easy_setopt(hnd, CURLOPT_INTERFACE, NULL); curl_easy_setopt(hnd, CURLOPT_KRBLEVEL, NULL); curl_easy_setopt(hnd, CURLOPT_TELNETOPTIONS, NULL); curl_easy_setopt(hnd, CURLOPT_RANDOM_FILE, NULL); curl_easy_setopt(hnd, CURLOPT_EGDSOCKET, NULL); curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT, 0); curl_easy_setopt(hnd, CURLOPT_ENCODING, NULL); curl_easy_setopt(hnd, CURLOPT_FTP_CREATE_MISSING_DIRS, 0); curl_easy_setopt(hnd, CURLOPT_IPRESOLVE, 0); curl_easy_setopt(hnd, CURLOPT_FTP_ACCOUNT, NULL); curl_easy_setopt(hnd, CURLOPT_IGNORE_CONTENT_LENGTH, 0); curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 0); curl_easy_setopt(hnd, CURLOPT_FTP_FILEMETHOD, 0); curl_easy_setopt(hnd, CURLOPT_FTP_ALTERNATIVE_TO_USER, NULL); curl_easy_setopt(hnd, CURLOPT_SSL_SESSIONID_CACHE, 1); /* curl_easy_setopt(hnd, CURLOPT_SOCKOPTFUNCTION, 0x804fa00); [REMARK] */ /* curl_easy_setopt(hnd, CURLOPT_SOCKOPTDATA, 0xbf82cb74); [REMARK] */ curl_easy_setopt(hnd, CURLOPT_POSTREDIR, 0); ret = curl_easy_perform(hnd); curl_easy_cleanup(hnd); return (int)ret; } /**** End of sample code ****/
_______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
