asmith Posted June 21, 2009 Share Posted June 21, 2009 Hi, In a script, I will give a file to a converter : e.g <?php exec('converter.exe file.ext'); ?> converter will convert the file in some time. (depends on the file size) When the converter is done, It will save a file to the same locaton as file.ext2 With the same script I need to file_get_content('file.ext2'); If I put that code after the exec line, It will probably give me the file not found error if it is in the middle of the conversion and no one has been generated yet. What is the fastest way to ask for the file EXACTLY after the conversion is done? I thought about putting a loop like <?php while (!file_exists('file.ext2')) continue; // If php is here, then file is generated file_get_content('file.ext2'); ?> Is it a good way? Any better and faster way? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/ Share on other sites More sharing options...
trq Posted June 21, 2009 Share Posted June 21, 2009 If I put that code after the exec line, It will probably give me the file not found error if it is in the middle of the conversion and no one has been generated yet. Your script will wait at the call to exec() before continuing. Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860584 Share on other sites More sharing options...
asmith Posted June 21, 2009 Author Share Posted June 21, 2009 oh ok, Nice What if the conversion fails or takes much time? Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860585 Share on other sites More sharing options...
trq Posted June 21, 2009 Share Posted June 21, 2009 Your script can't move on until your function call returns a result. Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860586 Share on other sites More sharing options...
asmith Posted June 21, 2009 Author Share Posted June 21, 2009 hmm, Possible to set a time to the exec? Like move on after 5 sec if no result from the exec? Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860588 Share on other sites More sharing options...
trq Posted June 21, 2009 Share Posted June 21, 2009 Nope. Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860596 Share on other sites More sharing options...
asmith Posted June 21, 2009 Author Share Posted June 21, 2009 Ok, Thanks a lot for the info Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860603 Share on other sites More sharing options...
Daniel0 Posted June 21, 2009 Share Posted June 21, 2009 What you can do is to fork the process, but it will only work on Linux/Mac. Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860621 Share on other sites More sharing options...
trq Posted June 21, 2009 Share Posted June 21, 2009 Even then, I wouldn't go forking within a web server environment. Quote Link to comment https://forums.phpfreaks.com/topic/163109-solved-how-to-find-out-that-the-conversion-is-done-and-ready/#findComment-860625 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.