【问题标题】:PHP exec or shell_exec not returning process id (PID) on Windows WampPHP exec 或 shell_exec 未在 Windows Wamp 上返回进程 ID (PID)
【发布时间】:2013-05-17 15:30:50
【问题描述】:

我在 Windows 7 上,使用 WampServer,并尝试使用 FFMPEG。

编码有效,但我无法从 exec() 中获取进程 ID 方法也不是shell_exec() 方法。

这是我的代码:

$cmd = C:\ffmpeg\bin\ffmpeg.exe -i "C:\...\4ch.wav"  -ar 44100 -ab 48000 -f mp3 -y "C:\...\enc_4ch.mp3"

这就是我试图用 shell_exec 做的:

shell_exec("nohup $cmd > /dev/null & echo $!");

并与 exec :

exec("nohup " . $this->_command . " > /dev/null 2>/dev/null &") ; // returns null
exec("nohup " . $this->_command . " > /dev/null 2>&1 &"); // also returns null 

请让我知道我做错了什么,因为我想稍后使用以下方法检查我的进程是否仍在运行:

private function is_process_running($proccess_id) 
    { 
        exec("ps $proccess_id", $process_state);
        return (count($process_state) >= 2);
    }

谢谢你

【问题讨论】:

    标签: php windows ffmpeg shell-exec pid


    【解决方案1】:

    您正在使用 echo $! 获取进程 ID,并且该特定命令在 Windows 上不可用,因为它是一个 unix shell 命令。程序链接应该可以工作:How to get PID from PHP function exec() in Windows?

    【讨论】:

    • 你的意思是使用tasklist ?
    猜你喜欢
    • 1970-01-01
    • 2012-01-29
    • 2013-02-23
    • 2017-08-18
    • 1970-01-01
    • 1970-01-01
    • 2011-11-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多