FAQ
Hi..

I'm trying to find a way to spawn, wait for and read stdout of child
processes that works on both win32 and *nix machines...

My main problems being...

It's not clear to me how a parent process can (under *nix) retrieve the
output of a forked child...

I can't get spawnv to work on win32. It always fails with 'OSError: [Errno
8] Exec format error' (and even if I did how do I retrieve it's stdout ??)

This is all for a minimal CGI capable HTTP server that I can use to test
scripts accross both platforms...

Any help very gratefully recvd..

Thanks,

t o b e
Orchestream
London

Search Discussions

  • Joerg Baumann at Oct 5, 2000 at 6:46 pm
    There is the CGIHTTPRequestHandler defined in the standard library.
    It basically is a minimal CGI capable HTTP server in combination with
    BaseHTTPServer.
    It has a run_cgi method whch does exactly what are you searching for.
    But I would suggest to use the existing classes BaseHTTP Server and the
    request_handler#

    Tobe wrote:
    Hi..

    I'm trying to find a way to spawn, wait for and read stdout of child
    processes that works on both win32 and *nix machines...

    My main problems being...

    It's not clear to me how a parent process can (under *nix) retrieve the
    output of a forked child...

    I can't get spawnv to work on win32. It always fails with 'OSError: [Errno
    8] Exec format error' (and even if I did how do I retrieve it's stdout ??)

    This is all for a minimal CGI capable HTTP server that I can use to test
    scripts accross both platforms...

    Any help very gratefully recvd..

    Thanks,

    t o b e
    Orchestream
    London
  • Alex Martelli at Oct 5, 2000 at 7:34 pm
    "Joerg Baumann" <joerg.baumann at stud.informatik.uni-erlangen.de> wrote in
    message news:39DCCC70.71056C01 at stud.informatik.uni-erlangen.de...
    There is the CGIHTTPRequestHandler defined in the standard library.
    It does not meet Tobe's request, which was:
    I'm trying to find a way to spawn, wait for and read stdout of child
    processes that works on both win32 and *nix machines...
    The library module you mention is Unix-only: it relies on fork/exec
    to run the child process for CGI.
    It's not clear to me how a parent process can (under *nix) retrieve the
    output of a forked child...
    It opens a pipe, sets the write-end as the child's stdout (then later
    closes it in the fork-parent's side), keeps and uses the read-end in
    the fork-parent (and closes it in the fork-child before the exec).
    I can't get spawnv to work on win32. It always fails with 'OSError:
    [Errno
    8] Exec format error' (and even if I did how do I retrieve it's stdout
    ??)

    I think some variation of popen is what you may be looking for. sys.popen
    should be fixed in recent versions (not sure about 1.6), but you can use
    the win32api module's version if you must ensure running with older
    Python releases (1.5.2).
    This is all for a minimal CGI capable HTTP server that I can use to test
    scripts accross both platforms...
    Sorry, I don't know of a ready-made one. It would be very nice to
    have a version of CGIHTTPRequestHandler modified to use popen
    and thus be cross-platform rather than Unix-only...


    Alex

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedOct 5, '00 at 4:11p
activeOct 5, '00 at 7:34p
posts3
users3
websitepython.org

People

Translate

site design / logo © 2023 Grokbase