acctman Posted August 27, 2007 Share Posted August 27, 2007 is there a way to use the exec fuction and wait till the processing is done before continuing with the rest of the coding? My problem is my EXEC function coding processes fine alone, but when I have other coding after it, its not waiting till the exec process is complete its going to the next step right after exec. Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/ Share on other sites More sharing options...
teng84 Posted August 27, 2007 Share Posted August 27, 2007 maybe you can use header file like if that is done then redirect Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-334976 Share on other sites More sharing options...
acctman Posted August 27, 2007 Author Share Posted August 27, 2007 maybe you can use header file like if that is done then redirect this is in a upload.php file that loads after the flash program receives the upload. I need for it to wait for exec($cmd); to finish before moving on. if ($_GET['type'] == 'mp3') { // Handle MP3 uploads if(!move_uploaded_file($_FILES['Filedata']['tmp_name'], $upload_path . session_id() . ".mp3")) { header("HTTP/1.0 500 Internal Server Error"); } // Change mp3 bitrate to 112 $mp3file = session_id(). ".mp3"; $cmd = '/usr/local/bin/lame -b 112 /home/site/public_html/temp/' . $mp3file . ' /home/site/public_html/temp/112_' . $mp3file; exec($cmd); $en = mysql_fetch_array(mysql_query("SELECT `m_date`, `m_id` FROM `rate_members` WHERE `m_id` = '".$_GET['userid']."' AND `m_user` = '". $_GET['user']."'")); // Add it to the database so we can FTP it. sql_query("INSERT INTO `site_mp3s` (`mp3_userid`,`mp3_title`) VALUES ('".$en['m_id']."', 'Unknown MP3 Title')"); } Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-334980 Share on other sites More sharing options...
acctman Posted August 27, 2007 Author Share Posted August 27, 2007 any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335163 Share on other sites More sharing options...
acctman Posted August 27, 2007 Author Share Posted August 27, 2007 is it possible to use EXEC and have it wait till its done before processing the rest of the PHP coding? Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335551 Share on other sites More sharing options...
dbo Posted August 27, 2007 Share Posted August 27, 2007 I actually thought the default was for it to wait until execution stopped before reloading the page. I thought if you wanted it to run in the background you had to do some trickery... what platform are you running on, windows or *nix? Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335558 Share on other sites More sharing options...
acctman Posted August 27, 2007 Author Share Posted August 27, 2007 I actually thought the default was for it to wait until execution stopped before reloading the page. I thought if you wanted it to run in the background you had to do some trickery... what platform are you running on, windows or *nix? as you can see in the 3rd post i put part of the coding up. the exec with run perfectly fine if i put it in a file by itself. as soon as i add other coding after it, it doesn't work right. Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335596 Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 can't you use sleep? sleep(10); //stops code for 10 seconds Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335603 Share on other sites More sharing options...
dbo Posted August 27, 2007 Share Posted August 27, 2007 All I know is that I have a site I've been working on for a client (running on a windows server) that calls an external perl script... the script hangs until the script is executed and then continues with logic after it. I've not done any trickery to get it to work this way. Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335613 Share on other sites More sharing options...
acctman Posted August 27, 2007 Author Share Posted August 27, 2007 i found the problem it was my oversight... part of my coding at the end was (see below)... the ftp was moving the original session file over I forgot to put 112_ so it made it look like it wasn't process when it actually was but both fils were being deleted so i didn't notice. I was wrong Exec does wait to complete before continuing process of coding. if(ftp_new_image("public_html/" . date("Y", $en['m_date']) . "/" . date("m", $en['m_date']) . "/" . $en['m_id'] . "/" . $srcdir, $en['m_id'] . "-" . $mp3_file . ".mp3", "/home/site/public_html/temp/112_" . session_id() . ".mp3")); // Ok Now lets clean up since everything worked! unlink("/home/site/public_html/temp/" . session_id() . ".mp3"); unlink("/home/site/public_html/temp/112_" . session_id() . ".mp3"); Quote Link to comment https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335621 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.