shell_exec causing CGI ERROR

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mattrapoport@gmail.com

    shell_exec causing CGI ERROR

    I have a php page that needs to call a batch script. My test script
    has one line: echo test.

    I am running Win2003 Server, IIS, and php 4.3.10.

    When I first tried running my php script I got an error that said
    "unable to execute ...". Then I granted the IIS user execute
    privledges to cmd.exe (I know, I know ... security risk).

    Once I did that, my script gives me a CGI ERROR - something about http
    headers.

    I've scoured google groups and come up with nothing that works. I
    tried one solution that uses an executable called bgrun.exe. That exe
    calls my batch script - still no luck. I've tried exec() and
    shell_exec(). No difference. I've tried saving the result to a
    variable and not. No difference.

    Any help would be greatly appreciated.

    Thanks,

    Matt

  • IBRAYEM

    #2
    Re: shell_exec causing CGI ERROR

    try system() command instead of exec(). e.g.

    consider following example taken from PHP Manual

    <?php
    echo '<pre>';

    // Outputs all the result of shellcommand "ls", and returns
    // the last output line into $last_line. Stores the return value
    // of the shell command in $retval.
    $last_line = system('ls', $retval);

    // Printing additional info
    echo '
    </pre>
    <hr />Last line of the output: ' . $last_line . '
    <hr />Return value: ' . $retval;
    ?>

    Comment

    • mattrapoport@gmail.com

      #3
      Re: shell_exec causing CGI ERROR

      Nope. I entered it exactly as written in your post (and in the php
      manual). Still no luck.

      I've given up. I'm switching to apache.

      - Matt

      Comment

      Working...