Jump to content

Smartest way to redirect stream php://stdin


mailjol

Recommended Posts

Well I am running a PHP program through CLI. I want the most resource efficient and fast way for the data that has been passed to it on STDIN to get redirected to some other PHP script started through exec, system, popen etc and the calling script to exit immediately. For example when all text inside data.txt is passed to script1.php:

cat data.txt | ./script1.php

The stream php://stdin contains this data. I want script1.php to start script2.php, pass the data of php://stdin to script2.php and exit. Script2.php will take some time to exit as it will deal with the data so I don't want script1.php to wait.

BTW I am using PHP 4.4.0 so I don't have access to all those stream functions of PHP 5.

Regards,
Akash
Link to comment
https://forums.phpfreaks.com/topic/34952-smartest-way-to-redirect-stream-phpstdin/
Share on other sites

In order to do that, you have to close STDIN, STDOUT, STDERR. Seeing your using PHP 4, the best way to do that will depend on the system, because PHP 4 doesn't have any native way to do this. So the only way to attack this is using a system process with PHP, depending on the system will tell me which way is best. So what OS is PHP running on!

printf

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.