I'm trying to execute a perl cgi from within 2 PHP scripts using either system() or exec().

one php script executes the other php script which then should excute the perl cgi through a simulated form post using the header function. it works when the header is used in a plain php script but fails whenever the second script is executed using system() or exec(). I can't execute the cgi directly :
exec("/usr/local/perl /path/perl.cgi $var1 $var2"); as it expects var/value pairs and I don't know perl enough to recode the script.

Any Ideas ?

calling script:
<?
// calling script
execute="/home/myaccount/www/clearzone/admin/encryp.php";
exec("/usr/local/php -q $execute test &");
// or
//system("/usr/local/php -q /home/myaccount/www/clearzone/admin/encryp.php test");
?>

encryp.php
<?
// use header to send var/value pairs to perl script
$subject=test;
$redirect="final.php";
Header("Location: ../enc.cgi?subject=$subject&redirect=$redirect");
?>

Many thanks,
Peter

    If I recall my CGI protocol specification, isn't the server supposed to pass the query string directly to stdin (with POSTed data in an environment variable)?

    exec("...perl.cgi subject=$subject&redorect=$redirect")

      OK,
      I've gotten virtual() to execute my perl script but only when calling encryp.php directly from my browser. It does not execute when encryp.php is called/executed via any of the following system() or exec().

      system("/usr/local/php -q /home/myaccount/www/clearzone/admin/encryp.php >/dev/null 2>&1");
      system("/usr/local/php -q /home/myaccount/www/clearzone/admin/encryp.php");

      $execute="/home/myaccount/www/clearzone/admin/encryp.php";
      exec("/usr/local/php -q $execute >/dev/null 2>&1");
      exec("/usr/local/php -q $execute");
      exec("/usr/local/php -q $execute &");

      Hoping there is some obscure but simple trick to get this to fire !
      ??

        You can't just include('encryp.php')?

          you can also simply fopen that file if it's CGI but this would require you to open it as a remote file like

          fopen("http://localhost/cgi-bin/somthing.cgi?dosomething=valuesomething");

          But this would be a worse solution to the problem when it's compared to exec() or system().. But if you're having problem with encryp.php you can use it for that one..

            Write a Reply...