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