简体   繁体   English

如何通过python在远程启动CGI脚本

[英]How to launch cgi script on remote via python

I would like to know if there is a python alternative to following curl command: 我想知道是否有python替代以下curl命令:

curl https://$ip/some_folder/some_script.cgi -k -u $user:"$pass" --interface $some_ip --connect-timeout 20 --max-time 30 -s

Sorry if this question is too basic but i am a python noob. 抱歉,这个问题太基本了,但是我是python noob。

Thank you in advance for any help. 预先感谢您的任何帮助。

You are essentially looking for the proper formulation of httplib.HTTPSConnection(TheURL, [options]) in Python 2.6, or urllib.request.urlopen(TheURL, [etc]) in Python 3. 您实质上是在寻找python 2.6中的httplib.HTTPSConnection(TheURL, [options])或Python 3中的urllib.request.urlopen(TheURL, [etc])的正确表述。

HTTPSConnection is a class, not an event, so when you create it you will need to set it up the way you want according to whatever you were expecting from curl. HTTPSConnection是一个类,而不是事件,因此在创建它时,您将需要根据curl所期望的方式按照所需的方式对其进行设置。

Here are the relevant docs for Python2.6 and Python3.4 . 这是Python2.6Python3.4的相关文档。 Your -k option simply makes insecure HTTPS OK, and the user/pw thing will have to be done by handling the request or including it in the request, I believe. 您的-k选项仅使不安全的HTTPS正常,并且我认为必须通过处理请求或将其包含在请求中来完成用户/密码操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM