CGI脚本中的Shebang系列应该是什么? [英] What should be the Shebang line in a CGI script?

查看:92
本文介绍了CGI脚本中的Shebang系列应该是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了以下操作并且无法运行CGI脚本:


#!c:/ program files / perl / perl

# !/ usr / bin / perl

#!C:/ Program Files / Apache Software Foundation / Apache2.2 / cgi-bin /


谢谢

I''ve tried the following and unable to run the CGI script:

#!c:/program files/perl/perl
#!/usr/bin/perl
#!C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/

thank you

推荐答案

Windows中的shebang行通常被忽略。但是,根据TSDN上的其他人的说法,Apache会看到它,如果你指定为Taint模式,那么它就会被打开:

The shebang line in Windows is typically ignored. But, according to others here on TSDN, Apache will see it and see that Taint mode is turned on if you have it specified as:

展开 | 选择 | Wrap | 行号


是的,将shebag行指向perl,而不是apache:


#!c:\perl \ bin \ perl.exe


由于窗口不区分大小写,您可以使用全部小写或任何大小写。


如果你把perl放在命令路径中,你可以简单地使用:


#!perl


你也可以设置apache在windows上不使用shebang line。我忘了如何,但也许在apache论坛的人知道。我知道这是apache指令之一,但是我忘记了哪一个,而且我懒得去谷歌。


关注windows的另一个好处就是你可以在路径语句中使用正斜杠:


c:/perl/bin/perl.exe


同样适用,并且在perl中更安全代码,以避免元字符混淆。一个常见的误解是perl并不关心你是否在路径语句中使用正斜杠或反斜杠,这就是它适用于windows的原因。这是事实,perl并不关心,但是Windows本身支持这两种约定,它实际上与perl无关。从一开始,所有版本的Windows都支持路径语句中的前向或反斜杠。但DOS没有。因此,如果你必须向DOS发出一些东西,你必须在目录路径中使用反斜杠。正斜杠是DOS中的命令行开关。
Yes, point the shebag line to perl, not apache:

#!c:\perl\bin\perl.exe

Since windows in case-insensitive you can use all lower-case or any case.

If you put perl in the command path, you can simply use:

#!perl

You can also setup apache to use no shebang line on windows. I forget how but maybe someone in the apache forum knows. I know it''s one of the apache directives, but I forget which and I am too lazy to google for it.

Another good thing to be aware of with windows is that you can use forward slashes in path statements:

c:/perl/bin/perl.exe

works just as well and is safer in perl code to avoid meta character confusion. A common misconception is that perl does not care if you use forward or back-slashes in path statements and this is why it works with windows. That is true, perl does not care, but windows natively supports either convention, it really has nothing to do with perl. All versions of windows, since the beginning, support forward or back-slashes in path statements. But DOS does not. So if you ever have to shell out to DOS for something you must use back-slashes in directory paths. Forward-slashes are command line switches in DOS.


Numberwhun和Kevin,


谢谢你现在好了,我实际上可以运行了。 CGI在我的浏览器中。


但是在向.cgi脚本发送实际FORM时需要帮助,我是否也需要特定文件夹中的FORM(即post.html文件)?


目前我的.html文件在我的桌面上(post.htm),我在此模板中的操作行是:< form action =" /cgi-bin/post2.cgi" method =" POST">


当我点击post.html并填写表格并点击提交时,我收到以下错误:页面无法显示。


我现在哪里错了?我正在寻求你的帮助,因为Apache论坛的任何人都没有回应。


谢谢你们的
Numberwhun and Kevin,

Thanks it''s ok now, I can actually run .CGI in my browser.

However just need help when sending an actual FORM to the .cgi script, do I need the FORM (i.e. post.html file) in an particular folder too?

Currently my .html file is on my desktop (post.htm) and my action line in this template is: <form action="/cgi-bin/post2.cgi" method="POST">

When I click on post.html and fill out the FORM and click submit I get the following error: "The page cannot be displayed".

Where am I going wrong now? I''m seeking help from you as no one from the Apache Forum responds at all.

Thanks guy''s


这篇关于CGI脚本中的Shebang系列应该是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆