简体   繁体   English

VMS 上 Python 中的简单 CGI web 服务器

[英]Simple CGI web server in Python on VMS

I am trying to run an extremely simple CGI server on VMS done in python.我正在尝试在 python 中完成的 VMS 上运行一个非常简单的 CGI 服务器。

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.我遇到的问题是它正确地提供了 static 内容并尝试执行 CGI-s(它在正确的位置,并且我已经将这些 CGI 与 Apache 一起使用,因此该部分绝对不是问题)但它挂在某个地方。 It is something I don't know about VMS.这是我对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.更新:简化,我需要在 VMS 上执行一个程序并以某种方式获取该程序的结果。 Any reference to executing subprocesses and getting their results is enough for me.对执行子流程并获得结果的任何参考对我来说就足够了。

Are you using the Python port from http://hg.vmspython.org/vmspython/ ?您是否使用http://hg.vmspython.org/vmspython/的 Python 端口?

If so, I think this thread , and this file (which appears to implement a form of popen2 ), may hold the keys to your salvation.如果是这样,我认为这个线程这个文件(它似乎实现了popen2的一种形式)可能是你得救的关键。 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.端口中似乎有特定于 VMS 的模块(至少vms.starletvms.rtl.libvms.dvidefvms.clidef )为 VMS 的spawn function 等提供接口。 Documentation seems to be spotty or nonexistent, however.然而,文档似乎参差不齐或根本不存在。

CGIHTTPServer.py uses os.fork if available, subprocess.Popen if not. CGIHTTPServer.py使用os.fork如果可用, subprocess.Popen如果没有。

See the source code of the run_cgi method .请参阅run_cgi方法的源代码。

Experiment withe the subprocess module to see if/how it works on VMS.试验subprocess模块,看看它是否/如何在 VMS 上工作。

To execute a subprocess and get its output on posix:要在 posix 上执行子进程并获取其 output:

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.这显然是在 Linux 上,所以我不确定 Python 或子进程模块的任何 VMS 细节。

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

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

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