无法使用5行bash脚本运行apache cgi

时间:2019-11-19 08:36:04

标签: apache cgi

我的脚本很简单:

#!/bin/bash

echo "Content-type: text/html"
echo ''
echo 'CGI Bash example<br>'

它的权限为0755,如果我通过bash运行它,则会显示:

Content-type: text/html

CGI Bash example<br>

这是我从apache的error_log中得到的信息:

[Tue Nov 19 16:27:35.189462 2019] [:error] [pid 59428] syntax error at /srv/www/cgi-bin/test2.sh line 3, near "#line 1 /srv/www/cgi-bin/test2.sh\n#!/bin/bash\n\necho "Content-type: text/html""\n

有什么想法吗?

PS:我尝试使用python脚本

#!/usr/bin/env python

print('Content-type: text/html\r\n\r')
print('CGI Bash example<br>')

可在shell上正常运行并获得

[Tue Nov 19 16:32:25.078487 2019] [:error] [pid 59424] syntax error at /srv/www/cgi-bin/test2.sh line 4, near ")\nprint"\n

完全不知道。

0 个答案:

没有答案
相关问题