Vinay Shastry's blog

Posted Thu 27 April 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)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/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 ;
Category: misc

Comments