VMS 上使用 Python 编写的简单 CGI Web 服务器

发布于 2024-11-04 20:13:56 字数 498 浏览 0 评论 0原文

我正在尝试在用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岛歌少女 2024-11-11 20:13:56

您是否使用 http://hg.vmspython.org/vmspython/ 中的 Python 端口?

如果是这样,我认为此线程,并且此文件(它似乎实现了 的形式popen2),可能掌握着你得救的钥匙。似乎有特定于 VMS 的模块(至少有 vms.starletvms.rtl.libvms.dvidefvms .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 least vms.starlet, vms.rtl.lib, vms.dvidef, vms.clidef) in the port that provide interfaces to such things as VMS's spawn function. Documentation seems to be spotty or nonexistent, however.

倒数 2024-11-11 20:13:56

如果可用,CGIHTTPServer.py 使用 os.fork,如果不可用,则使用 subprocess.Popen

查看<的源代码代码>run_cgi方法

试验 subprocess 模块,看看它是否/如何在 VMS 上工作。

CGIHTTPServer.py uses os.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.

月下伊人醉 2024-11-11 20:13:56

要执行子进程并在 posix 上获取其输出:

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import Popen, PIPE
>>> output = Popen(['/bin/ls', '/'], stdout = PIPE).communicate()[0]
>>> print output
bin
boot
dev
etc
home
..snip..
root
sbin
>>> 

这显然是在 Linux 上,所以我不确定 Python 或子进程模块的任何 VMS 细节。

http://docs.python.org/library/subprocess.html

To execute a subprocess and get its output on posix:

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import Popen, PIPE
>>> output = Popen(['/bin/ls', '/'], stdout = PIPE).communicate()[0]
>>> print output
bin
boot
dev
etc
home
..snip..
root
sbin
>>> 

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文