os.system() and cgi

Steve Holden sholden at holdenweb.com
Sun Oct 28 16:51:32 EST 2001


"M. Ibaraki" <iamcanadian89 at yahoo.com> wrote ...
> This script (test.py) works fine and creates a file 'outputfile' when
> I run this in test mode (python test.py).
>
>
> --- test.py ----
> #!/usr/bin/python
>
> import cgi, os
>
> print "Content-type: text/html\r\n"
> print "<html>"
> print "<body bgcolor=white>"
>
> ret =  os.system('/usr/X11R6/bin/xmgrace -help > outputfile')
> # ret =  os.system('/bin/ls > outputfile')
>
> print "<p> ret = ", ret
> ----------------
>
>
>
> It shows:
>
> Content-type: text/html
>
> <html>
> <body bgcolor=white>
> <p> ret =  0
>
>
>
> However, when this is executed as a cgi it shows:
>
> ret = 256
>
> and no 'outputfile' file is created.
>
>
>
> Permission of /usr/X11R6/bin/xmgrace is:
> -rwxr-xr-x    1 root     root          450 May 20 18:48
> /usr/X11R6/bin/xmgrace
>
> xmgrace is a 2D plotting tool
> (http://plasma-gate.weizmann.ac.il/Grace/)
>
>
The problem is almost certainly because you are executing an X Window client
application in a context which makes it unable to open an X Window to
display its output. However, this is only a deduction from the documentation
you have referred to, which explicitly points out that "xmgrace" is the
GUI-based version of the program. You might get a better result by using
"grace" rather than "xmgrace".

You might also want to look at the error logs of your web server to see
whether you get any messages from the X Window system.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list