[prog] Calling a perl program from within PHP

Gareth Anderson somecsstudent at gmail.com
Fri Nov 12 16:54:01 EST 2004


Hi,

I'll state both of my problems in case their are any creative solutions :).

Currently I've created a CGI (perl) script to organise an online signatory list.
This list is going to tie into an authcate username/password system at
monash university australia.

Problem(s) 1

Cannot have a .htaccess file (which would easily do the
authentication) in a cgi-bin directory.
Cannot have a cgi script outside the cgi-bin directory (but can have
.htaccess outside there).
Cgi-wrap removes what I'm trying to get (the username).
Note that I require the username to make sure signatures are unique
and not faked.
So AFAIK its a dead-end considering the way things are setup, other
people have found this too from what I've discussed (excluding maybe
doing the authentication in perl which I don't understand).

Problem 2
Currently that server listed above doesn't support PHP, I'm going to
switch to one that does.

But everything I've written is in perl, and ideally I would use a
.htaccess and PHP file to call the perl executable or call it via
cgi-wrap as a CGI program.

Calling it as a CGI program might be a bad idea though because I'd
have to have the form in plain html (I would add the $REMOTE_USER as a
hidden parameter) with all the information, could I easily prevent
anyone from executing the CGI program manually (ie. allow only this
script to call my CGI program?).

***Or***
I could get the PHP to grab the $REMOTE_USER variable and everything I
need from the form and maybe pass it as command line parameters to a
perl script which would take care of storing the data (although now
its no longer a CGI script).

The perl script would be executable by myself only or something to
prevent outsiders from faking signatures....(and could only be called
by the PHP script which processes the form).

Is there any easy way to do it so the perl script can output to the
user (ie. when it prints it actually gets outputted to a webpage like
a CGI-script)?

Because currently the perl script does output webpages with the
results of what has being done, an ideal solution would be that I
could still do this and have the .htaccess work.

The reason for not using 100% PHP is the persistent hash on perl makes
programming (adding/removing not having duplicates) incredibly simple.

Sorry for the lack-of-details, there are a variety or problems I've
hit and they're difficult to explain.

I think PHP has a exec() option? Would that work?

Any ideas?

Note: This does not in any way relate to assessed work (assignments etc. etc.)

Regards,
Gareth


More information about the Programming mailing list