简体   繁体   中英

Running Python - 500 Internal Service Error

I have the following code (test.cgi):

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

The file is CHMOD 777 and so is the directory it is in.

I am getting the following error log

[Sun Apr 12 02:24:46.395628 2015] [cgi:error] [pid 3574:tid 34479148032] [client 172.17.240.2:19716] AH01215: env: python\r: : /fs5a/cheerupper/public/scripts/test.cgi
[Sun Apr 12 02:24:46.396715 2015] [cgi:error] [pid 3574:tid 34479148032] [client 172.17.240.2:19716] AH01215: No such file or directory: /fs5a/cheerupper/public/scripts/test.cgi
[Sun Apr 12 02:24:46.397453 2015] [cgi:error] [pid 3574:tid 34479148032] [client 172.17.240.2:19716] End of script output before headers: test.cgi

I am getting a 500 Internal Service Error when I try to run in a browser. I can run when SSHing into the server by the command line. I have tried on Namecheap servers and am now trying on NearlyFreeSpeech.net to the same results.

It looks like your file is saved with Windows newlines. Your editor should have an option to change it to Unix newlines, which your server expects.

short and simple CGI program:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM