os.system() and cgi

M. Ibaraki iamcanadian89 at yahoo.com
Sat Oct 27 09:21:46 EDT 2001


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