0

I am new to CGI Scripting. I have installed Wamp Server on Windows and Installed Python at Path D:\Installation\Python33.

I have written CGI Script (test.cgi) as:

print "Content-Type: text/html"
print
print "<html><head><title>Books</title></head>"
print "<body><h1>Books</h1>These are the books</body></html>"

I kept it under C:\wamp\www\ direcotry. When I run it from browser it gives me error "Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request."

I checked apache_error.log shows :

[Sun May 18 12:30:13 2014] [error] [client 127.0.0.1] (OS 3)The system cannot find the path specified.  : couldn't create child process: 720003: test.cgi
[Sun May 18 12:30:13 2014] [error] [client 127.0.0.1] (OS 3)The system cannot find the path specified.  : couldn't spawn child process: C:/wamp/www/test.cgi

I think Python Path needs to be set here.

I found similar question here :

internal server error (500) in simple cgi script

but could not find how to set python path on windows. Please help.

Thanks in advance.

Community
  • 1
  • 1
vijay
  • 494
  • 5
  • 17

3 Answers3

3

Finally found the solution:

I modified first line to setup python path and then used sys module to write the output as :

#!d:/Installations/Python33/python.exe

import sys
sys.stdout.write("Content-type: text/html\r\n\r\n")
sys.stdout.write("<html><head><title>Books</title></head>")
sys.stdout.write("<body><h1>Books</h1>These are the books</body></html>")

and It worked !!!

vijay
  • 494
  • 5
  • 17
0

place your script in C:\wamp\bin\apache\apache2.2.22\cgi-bin
(if you don't have cgi-bin folder then create one)

and then enable cgi in your "httpd.conf"

i.e. find <DIRECTORY /> and replace it with this(in your httpd.conf file)

<Directory />
Options FollowSymLinks +ExecCGI
AllowOverride None
Order deny,allow
Allow from all
</Directory>

for windows(on localhost)

#!D:\Installation\Python33
print("Content-Type: text/html")
print()
print("<html><head><title>Books</title></head>")
print("<body><h1>Books</h1>These are the books</body></html>")

and call your script like this

http://localhost/cgi-bin/yourfilename
ashishmaurya
  • 1,196
  • 10
  • 18
0

use this code in test.py

#!python

print ("Content-type: text/html\n")
print ("python test ok\r\n<br/>")
#print (help)
help (os.chmod())

and put D:\Installation\Python33 in path variable

restart apache

note: Wamp Server have to install in D drive.

I hope this will work

Masum Nishat
  • 358
  • 1
  • 15