Jump to content

Help with popen on linux?


Asus

Recommended Posts

Hello phpfreaks.I have problem with using popen() on linux.

 

On windows this code runs ok

 

<?php
popen('E:\php\php.exe E:\www\scr.php','r');
?>

 

But when i try on linux

 

<?php
popen('php /home/www/scr.php','r');
?>

 

 

Its simply doesnt work.Even if i try with full PHP path...

 

 

 

So anyone knows what the problem is and maybe possible solution? Also every alternative for popen() which works on win/unix is welcome.

 

 

Thanks a lot.

Link to comment
https://forums.phpfreaks.com/topic/180745-help-with-popen-on-linux/
Share on other sites

Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.

http://php.net/manual/en/function.popen.php

 

linux machine php ini set to safe mode??!

 

 

Yeah i already tried even with error handling but no success..

 

 

Here is mine full code

 

main.php

 

<?php
error_reporting(E_ALL);
$handle = popen('php /home/k/public_html/scr.php','r');
$h = fgets($handle);
echo $h;
?>

 

 

scr.php

 

<?php
error_reporting(E_ALL);
mail('[email protected]', 'popen', 'works');
echo "hello";
?>

 

But script only outputs:

 

X-Powered-By: PHP/5.2.9 

 

 

And doesnt sends email...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.