[prog] Calling a perl program from within PHP

Gareth Anderson somecsstudent at gmail.com
Mon Nov 15 18:21:32 EST 2004


Hi,

Another problem, this one I think is apache or PHP specific but I'm unsure....

Anyway, I can type php al-list-wrapper.php from the commandline and it
runs the perl perfectly (the php does a system call to the perl like:

system("/usr/bin/perl al-list.pl $REMOTE_USER $full_name $csse $anonymous");

I can run the perl manually from the command line it runs perfectly.

BUT when I run it through the web:
http://yoyo.its.monash.edu.au/~gja/protect/al-list-wrapper.php

I get no results, and I'm very unsure how to debug this kind of thing
you can't see.

Note that permissions are correct, as it works if I remove the
dbmopen() line from the perl code.

So I commented out everything and tried things until I got it working,
AFAIK the dbmopen() is the problem.
Its not allowing the perl function to create/open files in my
directory, which it needs to do.

Anyone familiar with this or know a way around?
I was planning not to re-write my perl solution in PHP because
system() works on my home server.
And the other one I found is passthru() in PHP which is for binary files.

Note normally system will output to the user, so whatever perl prints
ends up being the webpage...

Oh, and in case anyone wonders the perl is not executable from
outside...(must be run as user gja).

Code is avail here:
http://yoyo.its.monash.edu.au/~gja/allcode/

I should mention permissions are like this:

-rwxr-xr-x  1 gja  www    193 Nov 15 17:56 al-list-wrapper.php
-rwxr-xr-x  1 gja  www    193 Nov 15 17:52 al-list-wrapper.php~
-rwxr-xr-x  1 gja  www   4770 Nov 15 18:02 al-list.pl
-rwxr-xr-x  1 gja  www   4819 Nov 15 17:55 al-list.pl~


More information about the Programming mailing list