I am trying to use python CGI scripting on my server. Both the python and perl scripts displayed below are in the same directory, with permission 755.
If I try a python hello world using this code, and point the browser to it:
#!/usr/bin/env python
import cgi
import cgitb
cgitb.enable()
print "Content-type:text/html\r\n\r\n"
print "Hello, World!"
It fails with: Error 500: Premature end of script headers: cgiwrap
I think I have a cgiwrap
permission issue, as my server is apache, and I read that the -w
option in perl could bypass that kind of issue.
Interestingly, I tried with the perl Hello World provided on the host provider help page (which fails when run as is):
#!/usr/bin/perl
print "Content-type: text/html\r\n\r\n";
print "Hello World";
It fails with: CGIWrap Error: Script Execution Failed, Error Message: No such file or directory
While if I try to execute (only changing the shebang):
#!/usr/bin/perl -wT
print "Content-type: text/html\r\n\r\n";
print "Hello World";
it runs...
Furthermore, the command python index.py
in Terminal runs as expected, while ./index.py
fails with No such file or directory
The which python
command output: /usr/bin/python