从网页执行Perl脚本的最佳方法? [英] Best way to execute perl script from webpage?
问题描述
我需要从网页(在同一服务器上)在服务器的根目录中执行perl脚本.必须通过页面上的输入框将4个参数传递给此脚本,以使其起作用.
I need to execute a perl script in the root directory of my server from a webpage (on same server). 4 parameters need to be passed to this script from input boxes on the page for it to work.
做到这一点的最佳方法是什么?请指教.如有可能,请提供示例.
What would be the best way to do this? Please advise. If possible please provide an example.
非常感谢
推荐答案
像Apache这样的服务器具有/cgi-bin/
处理程序.您将请求
Servers like Apache have a /cgi-bin/
handler. You would make a request to
或类似的东西.这个script.pl实际上位于其他地方.一个常见的位置是/usr/lib/cgi-bin
.
or something similar. This script.pl actually resides elsewhere. One common location is /usr/lib/cgi-bin
.
我快速进行了有关如何完成此操作的屏幕截图.我以前只为Python做过此事,所以这对我来说是一次学与教.
I made a quick screen cast about how this would be done. I've only done this for Python before, so this was a learning and teaching at once for me.
视频链接:
- http://httpd.apache.org/docs/2.0 /mod/mod_mime.html#addhandler
- 教程
- 教程您好世界
- 页面地址: http://localhost/cgi-bin/test.pl
- http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addhandler
- tutorial
- tutorial hello world
- Page address: http://localhost/cgi-bin/test.pl
这是视频
我在命令行上输入注释来解释某些部分.我通常忘记的一种是chmod
脚本.如果它们不是可执行文件,则服务器将不会执行它们,而且您也不知道为什么.
I type comments on the command line explaining certain parts. One that I usually forget is to chmod
the scripts. If they aren't executable, the server won't execute them and you'll have no idea why.
这篇关于从网页执行Perl脚本的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!