【问题标题】:PHP shell_exec with screen and Ts3Musicbot带有屏幕和 Ts3Musicbot 的 PHP shell_exec
【发布时间】:2017-01-14 16:28:33
【问题描述】:

我正在为一些 Ts3Musicbots 开发 Web 界面,但我在启动屏幕时遇到了一个问题。

我的代码:(stackoverflow)

$cmd = "screen -d -m -L $botverzeichnis /mb/$botverzeichnis/start.sh -account $botacc -secretkey $secretKey -port $botport -webif-pw $adminpw -webif-pw-user $userpw -max-disk-space 100 -noquery"; 
$redirect = '2>&1';
// using variable substitution only for readability here 
shell_exec("$cmd $redirect", $output);

它并没有启动。当我打印出 $cmd 并将其放入 Putty 时,它就可以工作了!

启动脚本所在的目录目前位于 var/www/

请帮忙;)

【问题讨论】:

    标签: php linux shell-exec


    【解决方案1】:

    好吧,shell_exec 返回输出并且只有一个参数。应该是:

    $cmd = "screen -d -m -L $botverzeichnis /mb/$botverzeichnis/start.sh -account $botacc -secretkey $secretKey -port $botport -webif-pw $adminpw -webif-pw-user $userpw -max-disk-space 100 -noquery"; 
    $redirect = '2>&1';
    // using variable substitution only for readability here 
    $output = shell_exec("$cmd $redirect");
    

    见http://php.net/manual/en/function.shell-exec.php

    【讨论】:

    • 什么时候不需要输出?
    • 如果你不需要输出你不需要将它分配给一个变量,但你需要解释更多。你在做什么,你是怎么做的,你得到什么错误信息等等。
    • 我尝试在屏幕中启动一个 java 进程 (TS3Musicbot)。 shell_exec 的输出为 NULL
    • 好吧,如果我没记错的话,如果命令有效,shell_exec 屏幕的输出应该是 NULL...
    • 但我看不到屏幕,并且我的 url:2001 上必须显示 Web 界面
    猜你喜欢
    • 2015-10-30
    • 1970-01-01
    • 1970-01-01
    • 2014-05-10
    • 2011-08-13
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 1970-01-01
    相关资源
    最近更新 更多