The following script could be executed with nodejs:
I hacked it in the server console, that is why its not very pretty, i'll make a cleaned up version later.
It will execute gt and then print something like:
It is Day 50! Time is 13:44.
on your servers console and then exits. You could use this maybe to fetch day in an interval x, save it to a text file and then read it from wherever you want.
I called the script main.js so in my case i would execute "node main > output.txt"
You could also let the connection open and have nodejs updating the data in output.txt, maybe save as JSON string.
Code:
"use strict";
//exports.__esModule = true;
var net = require("net");
var port = 8081;
var host = "localhost";
var client = net.createConnection({port:port},()=>{
//console.log("Telnet connection established\n");
client.on("data",(c)=>{
let text = c.toString();
if(["\n","\r","\r\n"].indexOf(text)>=0) return;
if(text.match(/^day/i)){
let data = text.split(" ");
let day = data[1].replace(",","");
let time = data[2];
console.log(`It is Day ${day}! Time is ${time}.`);
client.write("exit\r\n","utf8");
} else{
// let out = text.replace(/\r\n$/gi,"").replace(/^\r\n/gi,"").replace(/^\n/gi,"");
// console.log(out);
}
});
client.on("end", function () {
// ITS OVER!
//console.log("Server gone!");
});
setTimeout((c)=>{ c.write("gt\r\n","utf8",()=>{
//console.log("sent gt to telnet");
}); }, 1000,client);
});
It will execute gt and then print something like:
It is Day 50! Time is 13:44.
on your servers console and then exits. You could use this maybe to fetch day in an interval x, save it to a text file and then read it from wherever you want.
I called the script main.js so in my case i would execute "node main > output.txt"
You could also let the connection open and have nodejs updating the data in output.txt, maybe save as JSON string.