6

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.

McKracken
  • 680
  • 8
  • 17
  • 1
    May be you should post the logs (set `debug=True` in those servers, if present) and give a link. Without these details it is hard to troubleshoot. – Senthil Kumaran May 03 '11 at 01:26
  • if I telnet to the port and do GET this is what I get: %DCL-W-NOCOMD, no command on line - reenter with alphabetic first character – McKracken May 05 '11 at 15:59

3 Answers3

1

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.

Nicholas Knight
  • 15,774
  • 5
  • 45
  • 57
0

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.

codeape
  • 97,830
  • 24
  • 159
  • 188
-1

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

tMC
  • 18,105
  • 14
  • 62
  • 98
  • Module subprocess is not available on VMS. Also fork() is not there at all. – McKracken May 25 '11 at 14:29
  • Holy crap- if there is no os.fork(), I'm not sure of your options. I think fork() is the underlying call for most? (all?) of the process creation functions/modules. subprocess, multiprocess, os.spawn*, etc. does os.system() exist? – tMC May 25 '11 at 14:49
  • Subprocesses work quite differently on OpenVMS. At the moment I do not have access to the compiler on the target platform, so Python is only available sane option. – McKracken May 25 '11 at 14:56
  • can you create subprocesses in the command shell, akin to coproc or & in bash? – tMC May 25 '11 at 15:14
  • Yes, you cans SPAWN a process from shell. – McKracken May 25 '11 at 16:32