Executing perl from php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
codetester
Forum Newbie
Posts: 3
Joined: Thu Aug 17, 2006 12:56 pm

Executing perl from php

Post by codetester »

Hi All,

I'm trying to run a perl script from within php, but it's not working as I think it should.
The perl file runs fine when executed on its own via the command line, so there is no problem there.
In php, I do the following:

system('perl script.pl');

But nothing happens. If I do something like:

system('copy test.txt test2.txt');

it works fine, but for some reason doesn't run perl.
I also tried using exec(), but that didn't work either. Also, in case it couldn't find the perl.exe, I copied that into the same directory as the php script, but nothing changed.
I'm running Apache (possibly I need to set something up in the php.ini file??).

Help would be appreciated as I'm banging my head against a wall right now!!

Thanks,

CT
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you sure perl is in the available paths that Apache has access to? These paths may not the be same ones you have access to when logged in as Apache likely runs under a different user.
codetester
Forum Newbie
Posts: 3
Joined: Thu Aug 17, 2006 12:56 pm

Post by codetester »

Well I tried placing the perl.exe into the same directory that the php script was in, but I got the same result.

Just to be sure, how do you add perl permissions to apache??
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I assume you're running Windows? In which case, it's typically selecting the file and/or path, right clicking and changing the permissions on it such that the user Apache runs under (which I believe is SYSTEM by default) has, at least, (I believe) execution rights. It may need read rights too.

Apache may need to be given rights to have interactive rights as well, which is done separately, but I can't remember how off the top of my head.

You may need/want to check your error logs to see if there is some other error that may be more simple than permissions.
codetester
Forum Newbie
Posts: 3
Joined: Thu Aug 17, 2006 12:56 pm

Post by codetester »

Hi,

Thanks for that, worked great.

Just for reference, I needed to change the 'Users' permissions, not SYSTEM, but that was the problem alright.
Post Reply