os.system() and cgi

Joonas Paalasmaa joonas at olen.to
Sat Oct 27 22:54:39 CEST 2001


iamcanadian89 at yahoo.com (M. Ibaraki) wrote in 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

Perhaps /usr/X11R6/bin/xmgrace fails because user, that is running Apache
can't open x-server.
Or something like that.



More information about the Python-list mailing list