Welcome Guest, Not a member yet? Register   Sign In
problem with shell_exec in a library.
#1

[eluser]oll[/eluser]
For the youtube-like website I'm developping for my work, I use the function below, with ffmpeg as Command, to convert a video file into flash, since it can take a long time to be converted (I redirect the output and then "ajax" it in a webpage, so that the user can go on doing something else meanwhile).
background process with php

Code:
function run_in_background($Command)
   {
           $PID = shell_exec("nohup $Command 2> /dev/null & echo $!");
   }

It works well with a simple PHP page.
It also works well with codeigniter if I put this function directly in the controller and call it with another function (for instance, index() )

Code:
$pid = $this->run_in_background($videofile);

It works means "I have the pid instantantly" and the web site goes on, while ffmpeg process in the background.

But I would like to use it with the library I created and it doesn't work.
It's defined as a method in my library (a simple copy/paste from this function in the library file)

I have another method, createflash(), in which there's a simple :

Code:
function createflash() {
//...
$this->pid = $this->run_in_background($this->filename);
//...
}

There's no error, but it waits for the function to finish (it can take several minutes) before finally displaying me the result . As if there wasn't the "nohup".

It looks like an instantiation behaviour problem, but I can't find where, since I'm far from being a specialist Wink

Thx.


Messages In This Thread
problem with shell_exec in a library. - by El Forum - 10-15-2008, 01:41 PM
problem with shell_exec in a library. - by El Forum - 10-19-2008, 04:47 AM
problem with shell_exec in a library. - by El Forum - 10-20-2008, 04:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB