0

我想知道是否有人知道我如何shell_exec()正确使用。我在php.ini文件中启用了它,但它似乎不起作用。

我必须使用用户名和密码登录外壳吗?

我将如何访问 screen -r through 上的内容shell_exec()

PS 我正在尝试在 Minecraft 服务器上运行 list 命令并返回数据。

4

2 回答 2

1

No you don't need to log into the shell, the shell will execute as the OS user executing your php commands. To begin, first test that you have shell_exec working properly:

<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>
于 2011-08-22T12:22:08.440 回答
0

You cannot use shell_exec with interactive commands. Since you are using screen simply enable the screen log and use file functions to read the screenlog.0 file created in the folder from where the screen was started.

于 2011-08-22T12:21:20.993 回答