Thursday, April 27, 2006

Non interactive modem telnet commands

If your modem supports telnet (most do), you can use this perl script to issue commands to the modem (reboot being the most used :P)


#!/usr/bin/perl

# Define values
$usercommand = "reboot";
$host = "192.168.1.1";
$username = "myusername";
$password = "mypasswd";

use Net::Telnet ();

$t = new Net::Telnet(); # or (Timeout => 10, Prompt => '/# $/');
$t->open($host);
$t->login($username, $password);
@output = $t->cmd(String => $usercommand,
Errmode => "return",
Timeout => "1" );

### Debug - print output ###
#print @output ;

1 comments:

Anonymous said...

Lame, perl sucks