Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   How to call perl script from HTML file using PHP tag ? (http://www.go4expert.com/forums/perl-script-html-file-using-php-tag-t19973/)

codestorm 3Nov2009 20:43

How to call perl script from HTML file using PHP tag ?
 
Hello,

I would like to execute perl script in an HTML page, using PHP code. I need to do this as both PHP and HTML cannot be parsed simultaneously using SSI codes in .htaccess files.

I am using the code for parsing PHP tags in my HTML pages. Now, I need to run a perl script also. How to do ? :disappoin

venami 7Nov2009 08:11

Re: How to call perl script from HTML file using PHP tag ?
 
Hi,

You can call/execute PERL script inside the PHP tags.

You need to download the PERL extension for PHP and add to PHP.

Then you can do like this:

Method 1: Call a PERL script file.
Code:

<?php
$perlobj = new Perl();
$perlobj->require("sample.pl"); // sample.pl is the PERL script file
$contents = ob_get_contents();
ob_end_clean();
print "Output: $contents";
?>

Method 2: Execute PERL script inside PHP.

Code:

<?php
$perobj = new Perl();
$perlobj->eval('print "Hello, this is a PERL script."');
?>


venami 7Nov2009 08:13

Re: How to call perl script from HTML file using PHP tag ?
 
In the second method, the contents inside the eval() function should be enclosed within single quotes, implying that eval() takes only one parameter as string and that is the PERL script itself.

codestorm 7Nov2009 21:51

Re: How to call perl script from HTML file using PHP tag ?
 
Hi,

Thanks for your solution. But, these methods won't work for me. I am working in a shared server platform and the package required for creating the perl object through "new Perl()" is not installed and not possible for installation also.

I need some htaccess way if possible. Also, I would like to know if there is some method by which PHP will run from HTML pages and also SSI will run to execute perl scripts.

Might be I am asking too much in one go :(

venami 12Nov2009 23:34

Re: How to call perl script from HTML file using PHP tag ?
 
Hi codestorm,

You can use SSI in your HTML file to run PHP and PERL scripts.

To run PHP:
Code:

<!--#include file='file_name.php' -->
To run PERL:
Code:

<!--#exec cmd='perl sample.pl' -->


All times are GMT +5.5. The time now is 01:39.