RuleBritannia Posted November 12, 2013 Share Posted November 12, 2013 (edited) Hello, I come accross this problem and im wondering how you may solve it. I believe I have one workign way but it might not be the best. So I am executing ffmpeg though php, and directing STDERR STDOUT to a log file, my php will run this without waiting for results. After the execution instance has been sent, I will check the log file to get some information directly after, The problem is, The log file has not yet been created, So it will not exist. Currently, I thought to call a loop allowing for a maximum of 10 seconds to pass checking each for log existence each second, If after 10 seconds there is still no log, assume error. Example just for theory purposes(not tested) $start = 1; $finish = 10; while($start <= $finish) { if($file_get_contents($log)) { $result = file_get_contents($log); $finish = 10; } sleep(1); $start++; } Im assuming this may work, But there maybe a better way to acheive this, How would you do it? Thanks Edited November 12, 2013 by RuleBritannia Quote Link to comment https://forums.phpfreaks.com/topic/283841-best-way-to-achieve-this/ Share on other sites More sharing options...
litebearer Posted November 12, 2013 Share Posted November 12, 2013 Just a couple of thoughts... 1. why haven't you tested? 2. I belive you mean to increment $start to 10 in your while loop rather than $finish (as $finish is already set to 10) Quote Link to comment https://forums.phpfreaks.com/topic/283841-best-way-to-achieve-this/#findComment-1458014 Share on other sites More sharing options...
RuleBritannia Posted November 12, 2013 Author Share Posted November 12, 2013 Just a couple of thoughts... 1. why haven't you tested? 2. I belive you mean to increment $start to 10 in your while loop rather than $finish (as $finish is already set to 10) 1. I have tested and it works, I just wrote this thread before implementing my theory, Assumed it would work because it wasnt very complex. 2. yes This approach works, But cant be the best way. Quote Link to comment https://forums.phpfreaks.com/topic/283841-best-way-to-achieve-this/#findComment-1458016 Share on other sites More sharing options...
RuleBritannia Posted November 12, 2013 Author Share Posted November 12, 2013 (edited) to those who maybe interested. I decided to take a differnt approach, instead of reading from a log file, I decided to wait for the process(let php hang) to finish and output results to a variable, then test for errors or success information, This way seems more reliable than checking for logs etc, too many problems can arise from this. Thanks Edited November 12, 2013 by RuleBritannia Quote Link to comment https://forums.phpfreaks.com/topic/283841-best-way-to-achieve-this/#findComment-1458043 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.