CURLOPT_QUOTE.md (4704B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_QUOTE 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CUSTOMREQUEST (3) 9 - CURLOPT_DIRLISTONLY (3) 10 - CURLOPT_POSTQUOTE (3) 11 - CURLOPT_PREQUOTE (3) 12 Protocol: 13 - FTP 14 - SFTP 15 Added-in: 7.1 16 --- 17 18 # NAME 19 20 CURLOPT_QUOTE - (S)FTP commands to run before transfer 21 22 # SYNOPSIS 23 24 ~~~c 25 #include <curl/curl.h> 26 27 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_QUOTE, 28 struct curl_slist *cmds); 29 ~~~ 30 31 # DESCRIPTION 32 33 Pass a pointer to a linked list of FTP or SFTP commands to pass to the server 34 prior to your request. This is done before any other commands are issued (even 35 before the CWD command for FTP). The linked list should be a fully valid list 36 of 'struct curl_slist' structs properly filled in with text strings. Use 37 curl_slist_append(3) to append strings (commands) to the list, and clear 38 the entire list afterwards with curl_slist_free_all(3). 39 40 Using this option multiple times makes the last set list override the previous 41 ones. Set it to NULL to disable its use again. libcurl does not copy the list, 42 it needs to be kept around until after the transfer has completed. 43 44 When speaking to an FTP server, prefix the command with an asterisk (*) to 45 make libcurl continue even if the command fails as by default libcurl stops at 46 first failure. 47 48 The set of valid FTP commands depends on the server (see RFC 959 for a list of 49 mandatory commands). 50 51 libcurl does not inspect, parse or "understand" the commands passed to the 52 server using this option. If you change connection state, working directory or 53 similar using quote commands, libcurl does not know about it. 54 55 The path arguments for FTP or SFTP can use single or double quotes to 56 distinguish a space from being the parameter separator or being a part of the 57 path. e.g. rename with sftp using a quote command like this: 58 59 "rename 'test/_upload.txt' 'test/Hello World.txt'" 60 61 # SFTP commands 62 63 ## atime date file 64 65 The atime command sets the last access time of the file named by the file 66 operand. The date expression can be all sorts of date strings, see the 67 curl_getdate(3) man page for date expression details. (Added in 7.73.0) 68 69 ## chgrp group file 70 71 The chgrp command sets the group ID of the file named by the file operand to 72 the group ID specified by the group operand. The group operand is a decimal 73 integer group ID. 74 75 ## chmod mode file 76 77 The chmod command modifies the file mode bits of the specified file. The 78 mode operand is an octal integer mode number. 79 80 ## chown user file 81 82 The chown command sets the owner of the file named by the file operand to the 83 user ID specified by the user operand. The user operand is a decimal 84 integer user ID. 85 86 ## ln source_file target_file 87 88 The **ln** and **symlink** commands create a symbolic link at the 89 target_file location pointing to the source_file location. 90 91 ## mkdir directory_name 92 93 The mkdir command creates the directory named by the directory_name operand. 94 95 ## mtime date file 96 97 The mtime command sets the last modification time of the file named by the 98 file operand. The date expression can be all sorts of date strings, see the 99 curl_getdate(3) man page for date expression details. (Added in 7.73.0) 100 101 ## pwd 102 103 The **pwd** command returns the absolute path of the current working 104 directory. 105 106 ## rename source target 107 108 The rename command renames the file or directory named by the source 109 operand to the destination path named by the target operand. 110 111 ## rm file 112 113 The rm command removes the file specified by the file operand. 114 115 ## rmdir directory 116 117 The rmdir command removes the directory entry specified by the directory 118 operand, provided it is empty. 119 120 ## statvfs file 121 122 The statvfs command returns statistics on the file system in which specified 123 file resides. (Added in 7.49.0) 124 125 ## symlink source_file target_file 126 127 See ln. 128 129 # DEFAULT 130 131 NULL 132 133 # %PROTOCOLS% 134 135 # EXAMPLE 136 137 ~~~c 138 int main(void) 139 { 140 struct curl_slist *cmdlist = NULL; 141 cmdlist = curl_slist_append(cmdlist, "RNFR source-name"); 142 cmdlist = curl_slist_append(cmdlist, "RNTO new-name"); 143 144 CURL *curl = curl_easy_init(); 145 if(curl) { 146 CURLcode res; 147 curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/foo.bin"); 148 149 /* pass in the FTP commands to run before the transfer */ 150 curl_easy_setopt(curl, CURLOPT_QUOTE, cmdlist); 151 152 res = curl_easy_perform(curl); 153 154 curl_easy_cleanup(curl); 155 } 156 157 curl_slist_free_all(cmdlist); 158 } 159 ~~~ 160 161 # HISTORY 162 163 SFTP support added in 7.16.3. *-prefix for SFTP added in 7.24.0 164 165 # %AVAILABILITY% 166 167 # RETURN VALUE 168 169 curl_easy_setopt(3) returns a CURLcode indicating success or error. 170 171 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 172 libcurl-errors(3).