Jump to content

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

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.

Link to comment
https://forums.phpfreaks.com/topic/66817-solved-exec-question/#findComment-335613
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.