2015-12-13 42 views
0

我使用的是使用Vmware的Ubuntu 12.04並且在Python cgi-bin上工作。我正在學習本教程:http://archive09.linux.com/feature/136602。我example1.py "Hello, Linux.com!"成功打印,但example2.py是不是和服務器不斷地說:Python 2.7.8在標題之前輸出腳本結尾:te.py

Server error! 

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

Error message: 
End of script output before headers: te.py 

If you think this is a server error, please contact the webmaster. 
Error 500 
localhost 
Apache/2.4.16 (Unix) OpenSSL/1.0.1p PHP/5.6.12 mod_perl/2.0.8-dev Perl/v5.16.3 

而且代碼:

#!/usr/bin/python 
import cgi 
print "Content-type: text/html" 
print 
form = cgi.FieldStorage() 
laptops = form.getvalue('laptops','0') 
desktops = form.getvalue('desktops','0') 
print """ 
<html> 
<body> 
<form action='second.py'> 
How many laptops do you own?&nbsp; 
<input type='radio' checked name='laptops' value='0' />0&nbsp; 
<input type='radio' name='laptops' value='1' />1&nbsp; 
<input type='radio' name='laptops' value='2' />2 
<p> 
How many desktops do you own?&nbsp; 
<input type='radio' checked name='desktops' value='0' />0&nbsp; 
<input type='radio' name='desktops' value='1' />1&nbsp; 
<input type='radio' name='desktops' value='2' />2 
<p> 
<input type='submit' /> 
<p> 
You own %d computers. 
</form> 
</body> 
</html>""" % (int(laptops)+int(desktops)) 

我自己失敗,並不能找出原因。請幫忙

回答

0

看起來你已經提供了Python路徑,你可以檢查你是否提供了執行許可文件?我想添加執行權限將解決您的錯誤。

+0

chmod + x ?????? – user3440716

+0

befor執行我做搭配chmod + X example2.py – user3440716

+0

是嘗試給搭配chmod -R 777 example2.py和檢查 –

相關問題