1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

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

Discussion in 'JavaScript and AJAX' started by codestorm, Nov 3, 2009.

  1. codestorm

    codestorm New Member

    Joined:
    May 20, 2008
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    India
    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
     
  2. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    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."');
    ?>
    
     
  3. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    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.
     
  4. codestorm

    codestorm New Member

    Joined:
    May 20, 2008
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    India
    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 :(
     
  5. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    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' -->
    
     
    shabbir likes this.

Share This Page