Tag Archives: phone

Command line dialing on Cisco 7940/7960 IP Phone

I decided to share my perl script which I am using to dial numbers on my Cisco 7960 from command line. It can be used for integration with callto:// links, PIM or just to dial from console. To dial script using telnet interface on the phone, so it must be enabled. Script using “test” which emulates buttons on the phone. Pause between commands is required to work correctly, without it phone will go mad.

#!/usr/bin/perl

use Net::Telnet;
use Time::HiRes;

# cisco phone host name
my $host='10.0.0.1';
# cisco phone password
my $password='cisco';
# mute on a dial 0/1
my $mute=0;

my $sleeptime=.2;
my $prompt='/> $/';

my $argc = @ARGV;
if ($argc!=1){
    print "Usage: call.pl <number>\n";
    exit;
}
my $number=@ARGV[0];

if($number!~/^[0-9*#]+$/) {
    print "Error: wrong characters in the numer\n";
    exit 2;
}
$telnet = new Net::Telnet ( Timeout=>3, Errmode=>'die');
# connecting
$telnet->open($host);
$telnet->waitfor('/Password :$/i'); 
$telnet->print($password); 
$telnet->waitfor($prompt);

$telnet->print('test open');
$telnet->waitfor($prompt);
$telnet->print('test key spkr');
$telnet->waitfor($prompt);Time::HiRes::sleep($sleeptime);
if($mute){
    $telnet->print('test key mute');
    $telnet->waitfor($prompt);Time::HiRes::sleep($sleeptime);
}
$telnet->print("test key ".$number."#");
$telnet->waitfor($prompt);Time::HiRes::sleep((length($number)+1)*$sleeptime);
$telnet->print('test close');
$telnet->waitfor($prompt);
$telnet->close($host);
Tagged , , ,