How can I call Perl from my PHP page on apache?

☆樱花仙子☆ 提交于 2019-12-11 02:27:33

问题


my friend and I are creating a log parser for a series of games. We have written the frontend (web) in PHP/MySQL and the parser in Perl (also using MySQL, of course). Now we are having problems getting these two to communicate.

All we wan't to do is this: one administration page online where you have the button "parse". When you click this a Perl script should start. Like "exec("perl /home/www/Init.pm -f games_mp.log").

Is this possible? Remember, it's suppose to be easy to set up.

We've tried everything from system/exec to .htaccess, but nothing seems to work out of the box. Not working at all really.

Suggestions?

laka =)


回答1:


I'm sorry to say there's no easy way to set this up. Different servers come with different default apache configs.

What you're probably looking to do is add the following line inside the either the server config, virtual host config, directory config, or, if properly setup, .htaccess.

AddHandler cgi-script .cgi .pl .pm

Your users will also need to chmod and chown the files appropriately.

Thing is, this sounds like a long running process. If it is, then it might take so long to run the web browser will time out before it is done. If that's the case, you'll likely want to setup some kind of job queue and have a cron script exec based off that every 5 min or so.




回答2:


Why not run the Perl script as if they were a web page from jQuery using mod_perl?




回答3:


I'm willing to bet you are running into pathing errors. Try providing the full path to the Perl executable. For example:

exec("/usr/bin/perl /home/www/Init.pm -f games_mp.log")



回答4:


In PHP many things depend on configuration. Try looking into it as many operators can be disabled.

Check that Perl program has correct rights. Try running you Perl program from command line.



来源:https://stackoverflow.com/questions/827302/how-can-i-call-perl-from-my-php-page-on-apache

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!