[Tutor] Python question for beginners...

alan.gauld@bt.com alan.gauld@bt.com
Fri, 27 Aug 1999 09:50:13 +0100


> I am doing a cgi script.  I need the script to execute a program and
> return the program output as a variable preferably.
> I tried using os.system("/usr/local/bin/program") but that 

Look at os.popen(...)

BUT the other issue in CGI work is that your program will 
execute as the cgi or www user. Often that user has very 
restricted access to system commands and files (for good 
security reasons!)

> to work from within the script.  It works in the python interpretor

That could be the security restriction above....

> not within the script.  Maybe the os.execv command???I don't 

Almost certainly not - unless you os.fork() first.
execv will *replace* your Python program with whatever 
program you execute.

Alan G.