在libcurl中执行SFTP / FTP命令而不进行实际传输(Executing SFTP/FTP command in libcurl without actual transfer)
是否可以在libcurl中执行SFTP命令而无需实际进行文件传输。
我使用CURLOPT_QUOTE设置命令执行(实际文件删除),但在执行操作(并且执行成功,文件被删除)后,curl正在尝试上传或下载文件(基于CURLOPT_UPLOAD),因此我收到CURLE_REMOTE_FILE_NOT_FOUND错误错误码。
到目前为止我尝试了 - 没有设置URL导致“格式错误的网址错误”,设置CURLOPT_CONNECT_ONLY导致报价也没有执行。 有没有标准的方法?
curl_global_init(CURL_GLOBAL_DEFAULT); char temp[2000]; _snprintf(STRPARAM(temp),"%s://%s:%d/%s","sftp",m_url,m_port,a_ftpPath); curl_easy_setopt(m_curl, CURLOPT_URL,temp); _snprintf(STRPARAM(temp),"%s:%s",m_name,m_pass); curl_easy_setopt(m_curl, CURLOPT_USERPWD, temp); curl_easy_setopt(m_curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD); curl_easy_setopt(m_curl, CURLOPT_UPLOAD, 0L); curl_easy_setopt(m_curl, CURLOPT_READFUNCTION, NULL); curl_easy_setopt(m_curl, CURLOPT_NOBODY, 1L); curl_easy_setopt(m_curl, CURLOPT_HEADER, 1L); struct curl_slist *headerlist=NULL; _snprintf(STRPARAM(temp),"rm /%s",a_ftpPath); headerlist = curl_slist_append(headerlist, temp); curl_easy_setopt(m_curl, CURLOPT_QUOTE, headerlist); m_res = curl_easy_perform(m_curl); curl_easy_setopt(m_curl, CURLOPT_QUOTE, NULL); curl_easy_setopt(m_curl, CURLOPT_HEADER, 0L); curl_easy_setopt(m_curl, CURLOPT_NOBODY, 0L); curl_slist_free_all (headerlist); curl_global_cleanup();
Is it possible to execute SFTP command in libcurl without actual attempt of file transfer.
I set the command to execute (file deletion actually) using CURLOPT_QUOTE, but after executing the operation (and it executes successfully, file is deleted) curl is trying to upload or download file (based on CURLOPT_UPLOAD), so I get the CURLE_REMOTE_FILE_NOT_FOUND error error code.
What I tried so far - not setting the URL results in "malformed url error", setting CURLOPT_CONNECT_ONLY result in quote not executed as well. Is there any standard way?
curl_global_init(CURL_GLOBAL_DEFAULT); char temp[2000]; _snprintf(STRPARAM(temp),"%s://%s:%d/%s","sftp",m_url,m_port,a_ftpPath); curl_easy_setopt(m_curl, CURLOPT_URL,temp); _snprintf(STRPARAM(temp),"%s:%s",m_name,m_pass); curl_easy_setopt(m_curl, CURLOPT_USERPWD, temp); curl_easy_setopt(m_curl, CURLOPT_SSH_AUTH_TYPES, CURLSSH_AUTH_PASSWORD); curl_easy_setopt(m_curl, CURLOPT_UPLOAD, 0L); curl_easy_setopt(m_curl, CURLOPT_READFUNCTION, NULL); curl_easy_setopt(m_curl, CURLOPT_NOBODY, 1L); curl_easy_setopt(m_curl, CURLOPT_HEADER, 1L); struct curl_slist *headerlist=NULL; _snprintf(STRPARAM(temp),"rm /%s",a_ftpPath); headerlist = curl_slist_append(headerlist, temp); curl_easy_setopt(m_curl, CURLOPT_QUOTE, headerlist); m_res = curl_easy_perform(m_curl); curl_easy_setopt(m_curl, CURLOPT_QUOTE, NULL); curl_easy_setopt(m_curl, CURLOPT_HEADER, 0L); curl_easy_setopt(m_curl, CURLOPT_NOBODY, 0L); curl_slist_free_all (headerlist); curl_global_cleanup();
原文:https://stackoverflow.com/questions/13509709
最满意答案
你可以试试这个,
- ((?:(?!\((?:not|yes)\)).)*)(?=\s|$)
要么
- (.*?)(?=\s+\((?:not|yes)\)|$)
这将捕获所有字符,直到达到
space(yes)
或space(no)
或行尾。
相关问答
更多-
了解负面预测(Understanding negative lookahead)[2023-12-10]
Lookaheads不会消耗任何字符。 它只是检查lookahead是否可以匹配: a(?!b)c 所以这里匹配后它只是检查它是否遵循而不是b但不消耗那not字符(这是c ),并跟随c 。 如何a(?!b)c匹配ac ac | a ac | (?!b) #checks but does not consume. Pointer remains at c ac | c 积极的前瞻 积极的前瞻是相似的,因为它试图与前瞻中的模式相匹配 。 如果可以匹配,则正则表达式引擎继续匹配模式的其余部分。 如果 ... -
正则表达式负面前瞻(Regular expression negative lookahead)[2022-04-21]
一个负面的前瞻性说,在这个位置,以下正则表达式不能匹配。 我们来看一个简单的例子: a(?!b(?!c)) a Match: (?!b) succeeds ac Match: (?!b) succeeds ab No match: (?!b(?!c)) fails abe No match: (?!b(?!c)) fails abc Match: (?!b(?!c)) succeeds 最后一个例子是双重否定 :它允许b跟随c 。 嵌套的负面前瞻成为一个积极的前瞻: ... -
添加“?” 到最后一个引用之前的“*”。 这将使“*”非贪婪,即:它将在第一个引号停止匹配,而不是最后一个 /(href|src)?\="http:\/\/www\.mydomain\.com\/(?:(?!\.js).)*?"/ add a "?" to the "*" before the last quote. This will make the "*" non-greedy, ie: it will stop matching at the first quote, not the last / ...
-
试试这种模式: \\b(?!(?:AND|OR|NOT)\\b)[a-zA-Z]+\\s 我添加了一些单词边界(\ b)并使用了字符类[a-zA-Z] (您可以在不区分大小写的上下文中将其替换为[az])以避免延迟量词。 或更高性能(不区分大小写): \\b(?>(?>[b-mp-z])|(?!(?>and|or|not)\\b)[aon])(?>[a-z]*)\\s 如果你想匹配: 不带双引号或空格的双引号之间的单词: (?<=(\"?)\\b)(?!(?:AND|OR|NOT)\\b)[a-zA-Z ...
-
积极的Lookahead正则表达式(Positive Lookahead Regex)[2023-07-11]
^(?=.{8}$).+ 将匹配字符串 aaaaaaaa 推理: 括号内的内容是向前看的,因为它以?=开头。 预览中的内容被解析 - 它不是从字面上解释的。 因此,如果.{8}$匹配,则前瞻只允许正则表达式匹配(在这种情况下,在字符串的开始处)。 所以字符串必须是正好八个字符然后它必须结束,如$证明。 然后,+会匹配这八个字符。 ^(?=.{8}$).+ will match the string aaaaaaaa Reasoning: The content inside of the brackets ... -
最简单的解决方案是将可选空白的外观作为function检查的一部分: (?:pass)(?:word)?(?:[\ ]{0,1})(?:[:=;,]{1})(?![\ ]{0,1}function)(.[^\s]*) 更新了regex101 The simplest solution is to move the look for the optional whitespace to be part of the check for function: (?:pass)(?:word)?(?:[\ ]{0 ...
-
负面预测RegEx(Negative Lookahead RegEx)[2022-11-16]
您应该使用负面后视: (?你可以试试这个, - ((?:(?!\((?:not|yes)\)).)*)(?=\s|$) DEMO 要么 - (.*?)(?=\s+\((?:not|yes)\)|$) 这将捕获所有字符,直到达到space(yes)或space(no)或行尾。 DEMO You may try this, - ((?:(?!\((?:not|yes)\)).)*)(?=\s|$) DEMO or - (.*?)(?=\s+\((?:not|yes)\)|$) This would capture all the ...使用单词边界( \b )将为您提供所需的内容。 Javascript示例: /(?!The|Cross)(\b\w+ )Street/.test('Main Street') // => true /(?!The|Cross)(\b\w+ )Street/.test('Bank Street') // => true /(?!The|Cross)(\b\w+ )Street/.test('The Street') // => false /(?!The|Cross)(\b\w+ )Street/.test( ...这样做 ^(?!.*chrome).*(safari) BTW JavaScript不支持lookbehind但我发现lookahead没有问题。 你在说什么 (?!chrome)(safari) 那是在“safari”之前(零宽度,所以从s之前的光标开始),没有字符串“chrome”没有意义。 This will do it ^(?!.*chrome).*(safari) BTW JavaScript does not support lookbehind but I see no problem ...相关文章
更多- storm client command
- 基于HDFS的FTP
- linux下可以限制IP地址对FTP功能的访问吗?
- ftp登陆远程linux机器,并执行shell脚本,如何处理
- 《Windows 命令行详解手册(第2版)》(Windows Command-Line Administrator's Pocket Consultant, 2nd Edition)扫描版[PDF]
- 关于java ftp服务
- linux命令 Curl
- jsp程序在服务器上运行,如何将本地文件上传到ftp上
- 使用java实现ftp的上传与下载功能
- solr 建立索引 命令
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。