SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    CA
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    calling perl script from php

    I have a number of perl scripts that pull data from a mysql database. currently I am executing them as an exec cgi include file. This is slow. I have limited experience with php but imagine that there must be a way to call a perl script and include it's output in php without an include file.

  2. #2
    SitePoint Member panda's Avatar
    Join Date
    Mar 2003
    Location
    Melbourne, Australia
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using exec() or passthru()

    You could use exec() to collect the output of your perl script in a php array. You then have acecss to the data and can extract as much or as little as you want.

    For more information on exec():
    http://www.php.net/manual/en/function.exec.php

    Alternatively, if the perl script already formatted the data and you simply wanted to display it (surrounded by output from PHP) you could use passthru()

    For more information on passthru():
    http://www.php.net/manual/en/function.passthru.php

  3. #3
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    virtual() was mentioned earlier for this...
    Mike
    It's not who I am underneath, but what I do that defines me.

  4. #4
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As panda said; use exec(). Just make sure the file permissions are correct on the Perl file.
    PHP Code:
    <?
    exec
    ('whatever.pl');
    ?>
    Codestorm.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •