Jump to content

[SOLVED] exec, question


acctman

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/66817-solved-exec-question/
Share on other sites

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')");
}

Link to comment
https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-334980
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335596
Share on other sites

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");

Link to comment
https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335621
Share on other sites

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.