Page 1 of 1

Executing perl from php

Posted: Tue Oct 10, 2006 12:57 pm
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

Posted: Tue Oct 10, 2006 1:08 pm
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.

Posted: Tue Oct 10, 2006 1:21 pm
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??

Posted: Tue Oct 10, 2006 1:34 pm
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.

Posted: Wed Oct 11, 2006 4:57 am
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.