【发布时间】:2014-03-31 15:48:06
【问题描述】:
我正在用 php 编写一个 shell,我想显示与 bash 相同的输出。在 bash 中执行 sleep 10 & 时,您将得到 [1] <PID>。当我使用以下方式调用 shell 时,如何在 php 中执行相同操作:
if (preg_match("/&\s*$/", $command)) {
$this->$shell_fn($token, '/bin/bash -c ' . escapeshellarg($command) .
" > /dev/null");
return array(
'output' => '',
'cwd' => $path
);
}
$shell_fn 是指向 curl 调用的 shell_exec、exec 或 cgi 脚本的包装器的变量。是否有可能从 php 或使用 shell 获取 pid?
【问题讨论】: