当屏幕确实在运行时,找不到屏幕会话


No screen session found when a screen is definitely running

G'day,

我有一个运行游戏服务器的分离屏幕,我使用bash脚本 command.sh 向分离屏幕发送命令。

在终端中,我可以使用以下命令,服务器成功执行该命令:

./command.sh 'any command'

然而,一旦我使用PHP调用脚本,就会使用:

    <?PHP
        if($_POST) {
            $commandString = $_POST['inputCommand'];
            $output = shell_exec('./command.sh $commandString');
            echo "<pre>$output</pre>";
            }
    ?>

屏幕返回错误:

No screen session found.

我尝试将bash脚本的权限更改为777,并尝试将其放在web根目录中。

有人知道为什么php不能运行脚本,而我可以在终端中运行脚本吗?


其他请求信息

command.sh

 #!/bin/bash
 screen -S "minecraft" -X stuff "$@"$''015'

似乎您正试图与另一个用户(默认为www数据)一起从Web服务器启动php脚本

要向屏幕发送一些文本,您必须以屏幕所有者的身份运行命令,因为/var/run/screen/S-user/中的屏幕有700权限

请尝试更改您的字符串:

sudo-u owner_of_the_screen/command.sh$commandString