LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   could not execute bin folder of a package from cgi bin script using python (https://www.linuxquestions.org/questions/linux-server-73/could-not-execute-bin-folder-of-a-package-from-cgi-bin-script-using-python-937907/)

ashish hasani 04-03-2012 10:04 AM

could not execute bin folder of a package from cgi bin script using python
 
#!/usr/bin/python
import cgi, cgitb
cgitb.enable()
import os
import sys
form = cgi.FieldStorage()
pdb1 = form.getvalue('pdb')
template1 = form.getvalue('template')
os.chdir("/home/ashish/project/findsite-1.0/src")
os.system('../bin/findsite -s pdb1 -t template1 -o pdb1.findsite')

print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
print "<title>SITE FINDER</title>"
print "</head>"
print "<body>"

print "<h2> Selected pdb1 is %s</h2>" % pdb1
print "</body>"
print "</html>"

the above findsite function is working and giving outputs when run directly on the terminal using python filename.py and generating outputs but it is not running when embedded in cgi script. i have no idea why this is creating problem only when used with cgi script.
Iam using ubuntu 10.10 and apache2 server

es0teric 04-05-2012 12:18 AM

Apache limits CGI execution to certain directories, for security reasons. For example, if (on Ubuntu with Apache2) you put a Python script in /var/www/, then Apache will just spit back the code as HTML. If the script is inside of /usb/lib/cgi-bin/, however, it will be executed.

If you want to change which directories are allowed to execute things, there's a config file inside of /etc/apache2/.

Hope that helps.


All times are GMT -5. The time now is 07:35 PM.