PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Embedded CGI script using PHP passthru command

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Embedded CGI script using PHP passthru command

    For anyone else trying to embed CGI/Win32 version of search.cgi into a PHP script, and run it under Windows XP, the following may help (the PHP virtual() function is for Unix, and must be substituted for the passthru() which works in a different way):
    PHP Code:
    <?php
        
    //Windows Usage
        
    $QSTRING $_SERVER['QUERY_STRING'];
        
    putenv('REQUEST_METHOD=GET');
        
    putenv('QUERY_STRING='.$QSTRING);
        
    $command="C:\\dir\\directory\\another-subdiectory\\search.cgi";
        
    ob_start();
        
    passthru ($command);
        
    $results ob_get_contents();
        
    ob_end_clean();
        echo 
    $results;
    ?>
    By default, the output in $results include the HTML header (Content-type: text/html; charset=UTF-8); I think there is an option to disable this under Advanced tab, "Disable charset enforcing on search script".

    And I found there is no need to truncate the directory path to DOS 8.3 notation.

    Regards,
    Ian Tresman
    Last edited by iantresman; Apr-07-2007, 09:40 PM.

  • #2
    Thanks for that. In addition, there is also an option, detailed in our FAQ, to use, shell_exec to call the CGI on Windows / IIS.

    Comment

    Working...
    X