简体   繁体   English

有什么方法可以将屏幕内容打印到网页上?

[英]Any way to print contents of a screen to a web page?

I'm running a minecraft server on a screen (screen -X mc java -jar minecraft_server.jar). 我正在屏幕上运行minecraft服务器(屏幕-X mc java -jar minecraft_server.jar)。 Is there any way to print the contents of this onto a web page? 有什么方法可以将其内容打印到网页上吗? I was thinking it would be something along the lines of 我当时想这可能与

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

however this does not print anything. 但是,这不会打印任何内容。 I think it has something to do with the screens being per-user, is there any way to let php run this? 我认为这与每个用户的屏幕有关,有什么方法可以让php运行吗? Or is there anyway to output the screen to a file and still be able to attach to the screen? 还是有将屏幕输出到文件并仍然可以附加到屏幕的方法?

Thanks a ton! 万分感谢!

Edit: Answer below works well, however I would suggest http://phpshell.sourceforge.net . 编辑:下面的答案很好,但是我建议使用http://phpshell.sourceforge.net You can log into the terminal and display the console along with being able to chat. 您可以登录终端并显示控制台以及可以聊天。 However this is interactive, and would work only for admins. 但是,这是交互式的,并且仅适用于管理员。

Either of these should work. 这些都应该起作用。

<?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");
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM