Beispiel #1
0
 * @version     0.1 alpha
 * @author      Jesse Norell <*****@*****.**>
 * @copyright   2012 Jesse Norell <*****@*****.**>
 * @copyright   2012 Kentec Communications, Inc.
 * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache License
 * @link        https://github.com/jnorell/Net_Telnet
 */
require_once "Net/Telnet.php";
# Note this is used as both a hostname and as part of the command prompt
# (which works for our configuration, but check your own)
$cmts = 'arris-cmts';
try {
    $t = new Net_Telnet(array('host' => $cmts, 'debug' => false, 'telnet_bugs' => false));
    echo $t->login(array('login_prompt' => 'Login: '******'login_success' => "[{$cmts}]", 'login_fail' => 'Login failed', 'password_prompt' => 'Password: '******'prompt' => ' remote1> ', 'login' => 'root', 'password' => ''));
    $t->page_prompt('Type: <space> to page; <return> advance 1 line; Q to quit ', ' ');
    if ($t->send("manage\r") && $t->expect(" box#", "show\r") && $t->expect(" box#", "info\r") && $t->expect(" box#", "admin\r") && $t->expect(" admin#", "show\r") && $t->expect(" admin#", "info\r") && $t->expect(" admin#", "exit\r")) {
        $t->read_stream();
        echo $t->get_data();
    } else {
        echo "ERROR looking up system information\n\n";
    }
    // Arris CMTS 1000 changes how it handles line endings in BINARY mode,
    // so just disable BINARY:
    $t->send_telcmd(TEL_DONT, TELOPT_BINARY);
    $t->send_telcmd(TEL_WONT, TELOPT_BINARY);
    // our terminal will print chars on screen, disable echo
    $t->echomode('none');
    while ($t->online() && ($s = fgets(STDIN)) !== false) {
        $t->println($s);
        if (($ret = $t->read_stream()) === false) {
            break;