VMS 上使用 Python 编写的简单 CGI Web 服务器
我正在尝试在用 python 完成的 VMS 上运行一个极其简单的 CGI 服务器。
import sys
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
server_address=('',8080)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()
我遇到的问题是,它正确地提供静态内容,并尝试执行 CGI(它位于正确的位置,并且我已将这些 CGI 与 Apache 一起使用,因此该部分绝对不是问题),但它挂在某个地方。这是我对VMS不了解的事情。
任何指向正确方向的指针将不胜感激。 :)
更新:简单来说,我需要在 VMS 上执行一个程序并以某种方式获取该程序的结果。任何有关执行子流程并获取其结果的参考对我来说就足够了。
I am trying to run an extremely simple CGI server on VMS done in python.
import sys
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
server_address=('',8080)
httpd = HTTPServer(server_address, CGIHTTPRequestHandler)
httpd.serve_forever()
The problem I have is that it serves out static content properly and it tries to execute the CGI-s (it is in the right place, and Ihave used those CGIs with Apache so that part is definitely not the issue) but it hangs somewhere. It is something I don't know about VMS.
Any pointer to the right direction would be appreciated. :)
Update: Simplified, I need to execute a program on VMS and get the results of that program somehow. Any reference to executing subprocesses and getting their results is enough for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否使用 http://hg.vmspython.org/vmspython/ 中的 Python 端口?
如果是这样,我认为此线程,并且此文件(它似乎实现了
的形式popen2
),可能掌握着你得救的钥匙。似乎有特定于 VMS 的模块(至少有vms.starlet
、vms.rtl.lib
、vms.dvidef
、vms .clidef
)位于端口中,为 VMS 的spawn
函数等提供接口。然而,文档似乎参差不齐或不存在。Are you using the Python port from http://hg.vmspython.org/vmspython/ ?
If so, I think this thread, and this file (which appears to implement a form of
popen2
), may hold the keys to your salvation. There appear to be VMS-specific modules (at leastvms.starlet
,vms.rtl.lib
,vms.dvidef
,vms.clidef
) in the port that provide interfaces to such things as VMS'sspawn
function. Documentation seems to be spotty or nonexistent, however.如果可用,
CGIHTTPServer.py
使用os.fork
,如果不可用,则使用subprocess.Popen
。查看<的源代码代码>run_cgi方法。
试验
subprocess
模块,看看它是否/如何在 VMS 上工作。CGIHTTPServer.py
usesos.fork
if available,subprocess.Popen
if not.See the source code of the
run_cgi
method.Experiment withe the
subprocess
module to see if/how it works on VMS.要执行子进程并在 posix 上获取其输出:
这显然是在 Linux 上,所以我不确定 Python 或子进程模块的任何 VMS 细节。
http://docs.python.org/library/subprocess.html
To execute a subprocess and get its output on posix:
This is clearly on Linux, so I'm not sure of any VMS specifics to Python or the subprocess module.
http://docs.python.org/library/subprocess.html