0

在 html 文件中:

<!--#exec cgi="/cgi-bin/test.pl"-->

perl 脚本:

#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "<input type=\"hidden\" name=\"aname\" value=\"avalue\">\n";
print "<img src=\"/cgi-bin/script.pl\" />";

这不会给我一个“错误处理指令”错误,也不会输出我的 HTML 来代替标签。我还要补充一点,ssi 标签被替换为什么都没有。

4

1 回答 1

0

你确定脚本正在执行吗?如果您将某些内容打印到 STDERR,它会显示在错误日志中吗?

除此之外,我还有几点意见:

  1. 我很确定打印 Content-Type 是多余的,您(好吧,无论如何都是 Apache)已经通过提供包含 SSI 的 HTML 文件来做到这一点。 参考

  2. exec真的是为了运行像'ls -l'. 你应该include virtual改用。它还允许您向 url 添加参数。例如

    <!--#include virtual="/cgi-bin/example.cgi?argument=value" --\>
    
  3. 帮自己一个忙,用qq[]双引号代替。你不必逃避一切......例如

    print qq[< input type="hidden" name="aname" value="avalue"\b];
    
于 2010-06-01T21:56:48.610 回答