25/01/12 19:10
giocala88
Salve ragazzi ho creato una pagina web con la funzione exec() che converte un video da avi in mp3. La funzione va benissimo sia da shell che da php...ora però vorrei stampare a video lo status della conversione ed indicare all'utente a che punto è la stessa es: 10%,11%, 12% ... e così via. Esiste un modo per implementare una roba del genere? Io non saprei proprio da dove iniziare.
Comunque in rete ho trovato questo codice...
Pensate che potrebbe servirmi a qualcosa?
Grazie a tutti ...
Comunque in rete ho trovato questo codice...
<?php // You may use status(), start(), and stop(). notice that start() method gets called automatically one time. $process = new Process('ls -al'); // or if you got the pid, however here only the status() metod will work. $process = new Process(); $process.setPid(my_pid); ?> <?php // Then you can start/stop/ check status of the job. $process.stop(); $process.start(); if ($process.status()){ echo "The process is currently running"; }else{ echo "The process is not running."; } ?> <?php /* An easy way to keep in track of external processes. * Ever wanted to execute a process in php, but you still wanted to have somewhat controll of the process ? Well.. This is a way of doing it. * @compability: Linux only. (Windows does not work). * @author: Peec */ class Process{ private $pid; private $command; public function __construct($cl=false){ if ($cl != false){ $this->command = $cl; $this->runCom(); } } private function runCom(){ $command = 'nohup '.$this->command.' > /dev/null 2>&1 & echo $!'; exec($command ,$op); $this->pid = (int)$op[0]; } public function setPid($pid){ $this->pid = $pid; } public function getPid(){ return $this->pid; } public function status(){ $command = 'ps -p '.$this->pid; exec($command,$op); if (!isset($op[1]))return false; else return true; } public function start(){ if ($this->command != '')$this->runCom(); else return true; } public function stop(){ $command = 'kill '.$this->pid; exec($command); if ($this->status() == false)return true; else return false; } } ?>
Pensate che potrebbe servirmi a qualcosa?
Grazie a tutti ...
aaa