将屏幕内容打印到网页的任何方式


Any way to print contents of a screen to a web page?

我正在屏幕上运行minecraft服务器(screen-X mc-java-jar minecraft_server.jar)。有什么方法可以将其内容打印到网页上吗?我想这会是类似的东西

<?php
$console = exec(console.sh)
echo $console;
header("refresh: 5";);
?>

然而,这并没有打印任何内容。我认为这与每个用户的屏幕有关,有没有办法让php运行这个?或者,是否可以将屏幕输出到文件中,并且仍然可以连接到屏幕?

非常感谢!

编辑:下面的答案很有效,不过我建议http://phpshell.sourceforge.net.您可以登录终端并显示控制台,同时还可以聊天。然而,这是交互式的,并且只适用于管理员。

这两种方法都应该有效。

<?php
$logs = "PATH_TO_SERVER_LOGS/server.log";
$fh = fopen($logs, 'r');
$theData = fread($fh, filesize($logs));
fclose($fh);
echo $theData;
header("refresh: 5");
?>
<?php
//Replace ./server.log with the path to your server logs and make sure apache has the proper //permissions to read the file.
$file = file_get_contents('./server.log', true);
echo $file;
header("refresh: 5");
?>