hvle Posted July 2, 2008 Share Posted July 2, 2008 Hi guys, I have a script running on linux. This script spit out text (stdout) as it run. I want this text to pass directly to browser. I used passthru command to execute the script but browser will wait until this php script finished then display all the output at once. Is there a way to achieve this? thanks Link to comment https://forums.phpfreaks.com/topic/112871-script-passing-stdout-directly-to-browser/ Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 Is there a way to achieve this? Maybe, Ajax I should imagine. Link to comment https://forums.phpfreaks.com/topic/112871-script-passing-stdout-directly-to-browser/#findComment-579738 Share on other sites More sharing options...
btherl Posted July 2, 2008 Share Posted July 2, 2008 You can try ob_implicit_flush(1) This will not be enough if your webserver is compressing output though, so you must also ensure that zlib is not set to compress output in php.ini, and that mod_gzip is not active in the webserver. It's not enough to disable zlib after your script starts in my experience. Link to comment https://forums.phpfreaks.com/topic/112871-script-passing-stdout-directly-to-browser/#findComment-579751 Share on other sites More sharing options...
hvle Posted July 2, 2008 Author Share Posted July 2, 2008 Ajax: will not solve this Some experience I like to share: This is the output buffering in PHP, as btherl pointed out. I wouldn't want to change the good ini settings to get this work. If that's not the case, you can follow btherl instruction. I found that using ob_flush() and flush() can be somewhat help, although not ideally solve my problem. Link to comment https://forums.phpfreaks.com/topic/112871-script-passing-stdout-directly-to-browser/#findComment-579764 Share on other sites More sharing options...
trq Posted July 2, 2008 Share Posted July 2, 2008 I know what output buffering is and how it works, hence I didn't suggest it. Link to comment https://forums.phpfreaks.com/topic/112871-script-passing-stdout-directly-to-browser/#findComment-579766 Share on other sites More sharing options...
btherl Posted July 2, 2008 Share Posted July 2, 2008 Ajax can be used as well to achieve what you want. We use this at my workplace to regularly refresh output from a script. We also use ob_implicit_flush() for other applications. I believe the sajax method is more robust, as ob_implicit_flush() can fail for the various reasons listed in my earlier post. Some browsers will also not display anything until a certain amount of data is received, so you may have to start by printing some junk if you want to use the ob_implicit_flush() approach. Link to comment https://forums.phpfreaks.com/topic/112871-script-passing-stdout-directly-to-browser/#findComment-579851 Share on other sites More sharing options...
hvle Posted July 2, 2008 Author Share Posted July 2, 2008 Thanks, I will definitely take a look at sajax Link to comment https://forums.phpfreaks.com/topic/112871-script-passing-stdout-directly-to-browser/#findComment-580452 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.