簡體   English   中英

有什么方法可以將屏幕內容打印到網頁上?

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

我正在屏幕上運行minecraft服務器(屏幕-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");
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM