开发者

Python cgi weird behaviour

开发者 https://www.devze.com 2023-04-09 04:24 出处:网络
I have a simple CGI python script with an html output: print \"Content-Type: text/html\" print print hours,minutes,seconds,\",\"

I have a simple CGI python script with an html output:

print "Content-Type: text/html"
print
print hours,minutes,seconds,","

When I run it from my linux shell, it runs fine but when called from the browser, all I get is a blank page. I used to have this problem before when I 开发者_StackOverflow社区used CRLF EOF instead of LF but I changed that and it worked fine until some recent modification.

I don't know what to do when the script runs fine from shell but not when called from a browser.


<!-- SHTML Wrapper - 500 Server Error --> means that something is going wrong on the server. The most common cause in CGI scripts for this error is that there is an uncaught error in the CGI script itself, causing it to prematurely terminate. Your best bet is to check your Apache error logs. These will normally be in /var/log/<name of Apache install>/error.log (This could be /var/log/apache2/error.log or /var/log/httpd/error.log, etc.)

Since you've said that this works well in the shell, my guess is that this is an issue with sys.path (remember, Apache is a different user, it will have different settings), but I would need to see more to be certain.

Other issues could be:

  • Different Python version (3 vs. 2)
  • File has the wrong permissions (755 is the standard, I believe)
  • Syntax error somewhere in Python which is environmentally dependant
0

精彩评论

暂无评论...
验证码 换一张
取 消