【发布时间】:2017-06-08 18:32:11
【问题描述】:
我编写了一个简单的 HTML 代码,在提交时它会执行一个 bash 脚本。 该脚本位于正确的文件夹 (cgi-bin) 中。 当我在 Firefox 上加载此页面时。它给出了一个错误
/somePATH/cgi-bin/script.sh could not be opened because an unknown error occurred.
是脚本权限的问题吗?我试过了:
chmod 777
这是 HTML 代码的一部分。
<form action="cgi-bin/script.sh" method="post">
<input type="submit" value="Call my Shell Script">
</form>
编辑: 该脚本基本上只是打印日期:
#!/bin/bash
# get today's date
OUTPUT=$(date)
# script
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Demo</title></head><body>"
echo "Today is $OUTPUT <br>"
echo "You can do anything with this Schell Script"
echo "</body></html>"
【问题讨论】:
-
脚本是什么样的?
-
@ShammelLee 在问题中编辑
-
cgi-gin/script.sh的内容是什么?另外,请指定您的服务器/配置。 -
@ShammelLee 我在问题中添加了该脚本。我在本地主机上运行它并且 HTTP 服务正在运行
-
您是否在脚本顶部指定了 shebang 行(
#!/usr/bin/env bash或类似的)?