os.system() and cgi

Gillou nospam at bigfoot.com
Sat Oct 27 23:24:34 CEST 2001


Answer certainly is in the Web server log file (gci errors are usually here)
IMHO, Apache usually runs for user "nobody" who can run
/usr/X11R6/bin/xmgrace.
But perhaps this program needs other resources on which "nobody" has no
permission.

Hope this helped

--Gillou

"M. Ibaraki" <iamcanadian89 at yahoo.com> a écrit dans le message news:
ef98172c.0110270521.774c1604 at posting.google.com...
> 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/)
>
>
>
> I also tried '/bin/ls > outputfile' instead of '/usr/X11R6/bin/xmgrace
> -help > outputfile'. This 'ls' command is executed and it creates
> 'outputfile' in both cgi and test modes.
>
>
> Permission of /bin/ls is:
> -rwxr-xr-x    1 root     root        48316 Sep 15 12:54 /bin/ls
>
>
> Any comments would be greatly appreciated.
>
>
> M. Ibaraki





More information about the Python-list mailing list