avin / telnet-commander
Send packets of commands to your telnet devices
dev-master
2014-11-20 22:14 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 4.0.*
This package is not auto-updated.
Last update: 2024-11-19 03:16:34 UTC
README
Library to easy send packets of commands to your telnet based devices and recieve answers for processing
- Send commands to device
- Setup needful promt regexp
- Read answers
Example
In this example we login to DLink DES-3200, change time-zone and check results
$host = "192.168.1.10"; $host = 23; $username = 'john'; $password = 'secretpass' $commands = [ ['command' => $username, 'promt' => '/username:$/i'], ['command' => $password, 'promt' => '/password:$/i'], ['command' => "enable admin", 'promt' => '/#$/i'], ['command' => "mysecretpass", 'promt' => '/PassWord:$|#$/i'], ['command' => "config time_zone operator + hour 3 min 0", 'promt' => '/#$/i'], ['command' => "show time", 'promt' => '/#$/i'], ['command' => "", 'promt' => '/#$/i'], ]; try { //Setup connection $commander = new TelnetCommander($host, $port); $commander->setHasAuth(false); $commander->connect(); //Set commands $commander->setCommands($commands); //Execute commands $data = $commander->processCommands(); /* Process $data if you need... */ } catch (Exception $e) { echo $e->getMessage(); }