Problem making system calls with PHP scripts

Posted by mazin k. on Super User See other posts from Super User or by mazin k.
Published on 2010-03-08T00:16:27Z Indexed on 2010/03/08 0:32 UTC
Read the original article Hit count: 840

Filed under:
|
|
|

I have the following PHP script:

<?php
  $fortune = `fortune`;
  echo $fortune;
?>

but the output is simply blank (no visible errors thrown).

However, if I run php -a, it works:

php > echo `fortune`;
Be careful of reading health books, you might die of a misprint.
        -- Mark Twain
php >

Am I missing a config directive or something that would cause this?

Edit: So, I tried running my script using $ php-cgi fortunetest.php and it worked as expected. Maybe the issue is with Apache2?

© Super User or respective owner

Problem making system calls with PHP scripts

Posted by mazin k. on Super User See other posts from Super User or by mazin k.
Published on 2010-03-08T00:16:27Z Indexed on 2010/03/08 3:32 UTC
Read the original article Hit count: 840

Filed under:

I have the following PHP script:

<?php
  $fortune = `fortune`;
  echo $fortune;
?>

but the output is simply blank (no visible errors thrown).

However, if I run php -a, it works:

php > echo `fortune`;
Be careful of reading health books, you might die of a misprint.
        -- Mark Twain
php >

Am I missing a config directive or something that would cause this?

Edit: So, I tried running my script using $ php-cgi fortunetest.php and it worked as expected. Maybe the issue is with Apache2?

© Super User or respective owner

Problem making system calls with PHP scripts

Posted by mazin k. on Stack Overflow See other posts from Stack Overflow or by mazin k.
Published on 2010-03-08T00:16:27Z Indexed on 2010/03/08 5:21 UTC
Read the original article Hit count: 840

Filed under:

I have the following PHP script:

<?php
  $fortune = `fortune`;
  echo $fortune;
?>

but the output is simply blank (no visible errors thrown).

However, if I run php -a, it works:

php > echo `fortune`;
Be careful of reading health books, you might die of a misprint.
        -- Mark Twain
php >

Am I missing a config directive or something that would cause this?

Edit: So, I tried running my script using $ php-cgi fortunetest.php and it worked as expected. Maybe the issue is with Apache2?

© Stack Overflow or respective owner

Related posts about php

Related posts about php.ini