• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Read your linux console output

Raggaer

Godly Member
Joined
Jul 25, 2012
Messages
1,557
Solutions
8
Reaction score
957
Location
Spain
Maybe someone finds an use for this, what it does :

http://4.ii.gl/EohwsP.png

http://3.ii.gl/MLCfp.png

And the code :

Code:
$h = popen('cd /ot/forgottenserver && ./tfs', 'r');

        if ($h) {
            while (!feof($h)) {
                $buf = fread($h, 1024);

                $fileHandle = fopen("/var/www/public/stream.html", "a+");

                if ($fileHandle) {
                    fwrite($fileHandle, $buf);
                    fclose($fileHandle);
                }
            }

            pclose($h);
        }

It will write all the console output into the file you want, then you can load it with jQuery or something :3
 
This is nice! I think I'll use this in an upcoming server of mine.
 
as a .php file

PHP:
$h = popen('CODE TO OPEN SERVER', 'r');

        if ($h) {
            while (!feof($h)) {
                $buf = fread($h, 1024);

                $fileHandle = fopen("FILE TO WRITE LOG", "a+");

                if ($fileHandle) {
                    fwrite($fileHandle, $buf);
                    fclose($fileHandle);
                }
            }

            pclose($h);
        }
 
Does this work to read a screen as well?
$h = popen('screen -x otserver', 'r');
 
I don't think so. Problem is that it will read from console until OTS stop [same for' screen'] and it will close ots if you close that script. How to run ots from website? Use PHP SSH2 [connect like putty, start ots on screen etc.], but it's not easy to install.

How to read console in PHP? Save console to file and read that file:
To start ots use:

stdbuf -oL "./tfs" > console.log 2>&1
It saves all messages and errors that TFS shows to file 'console.log' in folder with TFS. Then you just need to open that file and use some jQuery/AJAX to update website (load new lines from file).

EDIT:
This is my 'panel' that uses PHP SSH2 to manage TFS 0.4:
http://skalski.at/files/files/BasicOTAdminPHP.zip
 
Last edited:
I don't think so. Problem is that it will read from console until OTS stop [same for' screen'] and it will close ots if you close that script. How to run ots from website? Use PHP SSH2 [connect like putty, start ots on screen etc.], but it's not easy to install.

How to read console in PHP? Save console to file and read that file:
To start ots use:
stdbuf -oL "./tfs" > console.log 2>&1
It saves all messages and errors that TFS shows to file 'console.log' in folder with TFS. Then you just need to open that file and use some jQuery/AJAX to update website (load new lines from file).

Woah didnt know that, thanks man.
 
Back
Top