A client for writing/reading commands to a host over telnet.
chaker2710/laravel-telnet is a Laravel package for a client for writing/reading commands to a host over telnet..
It currently has 0 GitHub stars and 142 downloads on Packagist (latest version v1.0.0).
Install it with composer require chaker2710/laravel-telnet.
Discover more Laravel packages by chaker2710
or browse all Laravel packages to compare alternatives.
Last updated
Update 08.10.2020 - borisuu: I've made this a composer package for easier install into other projects. No code changes made.
Telnet client implementation in PHP.
This code is based on https://github.com/ngharo/Random-PHP-Classes/blob/master/Telnet.class.php but was completely rewritten. I tried to keep interface compatibility as much as possible.
Things that I know not to work the same anymore:
Many things are still wrong (though it was like that in upstream versions too):
use Borisuu\Telnet\TelnetClient;
//Uncomment this to get debug logging
//TelnetClient::setDebug(true);
$telnet = new TelnetClient('127.0.0.1', 23);
$telnet->connect();
$telnet->setPrompt('$'); //setRegexPrompt() to use a regex
//$telnet->setPruneCtrlSeq(true); //Enable this to filter out ANSI control/escape sequences
$telnet->login('telnetuser', 'weak');
$cmdResult = $telnet->exec('ls /');
$telnet->disconnect();
print("The contents of / is: \"{$cmdResult}\"\n");
Alternatively, have a look at testTelnet.php:
$ ./testTelnet.php -h
$ ./testTelnet.php -u telnetuser -p weak -H 127.0.0.1 -P 23 -c "ls /"