--- Gordon Stewart <[EMAIL PROTECTED]> wrote:

> Ive got a PHP script,  and hjave a Perl(CGI) script set up, for a
> specific function...
> 
> Is it possible - Within the PHP script, to "activate" the Perl script,
> & assign the results/output  to a variable...
> 
> I'll then continue my PHP script to loop through the variable, &
> extract the result...
> 
> (the Perl script is already created - else where, I'm just using its
> function in my PHP script - easier than re-programming the PHP)
> 
> Example :-
> 
> $as = exec (script.pl);   ?? - or "system" ? Or another command ?
> 
> (Then loop - & extract the line I need)
> 
> I cant locate any on php.net that assigns the result to a variable
> 
> -- 
> G
> NZ community groups - [EMAIL PROTECTED]
> Freecycle Auckland :-
> http://groups.yahoo.com/group/AucklandFreecycle/

If you run your Perl script from the command line, what does it return?  If the
output is the value you want to pass to PHP then your desire to use exec() or a
similar function may work.  I'd use shell_exec().

Keep in mind that many systems put restrictions on where Perl scripts can be
placed to run in CGI mode.  The permissions and ownership and location must be
just so for the script and its directory.  It's one of the ~joys~ of working
with Perl/CGI.

If your script will run using a command like:

perl script.pl

then you might end up using that in your shell_exec() command.

Although your example does not include any arguments for the Perl scrips,
please keep security in mind when using any of the exec() or similar commands. 
If you must use any data which comes from the web user as part of the command,
be extra certain that it is fully validated to contain only the range of values
you expect and not sneaky arbitrary commands.  These would be run with the
perms of your webserver user and could open the door for a lot of misuse.

James

Reply via email to