[英]Forming a cURL command using string concatenation in Python
I'm trying to form a cURL using string concatenation in Python.我正在尝试使用 Python 中的字符串连接来形成 cURL。 I have a custom command and I'm not sure if I can use requests for this.我有一个自定义命令,我不确定是否可以使用请求。
cmd='curl -u admin:'+password+' -F file=@'+package+' -F name='+package+' -F force=false -F install=true http://'+ip+':5101/crx/packmgr/service.jsp'
print(cmd)
Error:错误:
curl -u admin:******** -F file=@abc_xyz.zip
-F name=abc_xyz.zip
-F force=false -F install=true http://8.8.8.8:5101/crx/packmgr/service.jsp
curl: no URL specified!
curl: try 'curl --help' or 'curl --manual' for more information
sh: line 1: -F: command not found
sh: line 2: -F: command not found
32512
And yes I have tried escape '' as well.是的,我也尝试过 escape '' 。 Didn't work.没用。
Any help would be greatly appreciated.任何帮助将不胜感激。 TIA TIA
Looks like your constructed command has line endings after the package
variable, try stripping it from extra symbols:看起来您构造的命令在package
变量之后有行尾,请尝试从额外的符号中剥离它:
package = package.strip()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.