Hi.
I´m looking for the way to access to routerboard and retrieve some data like signal,ccq, something diferent like snmp etc…
I start try with access by two diferent way without success:
1) The first is this perl script :
#!/usr/bin/perl
###############################################################################
use diagnostics;
use Net::Telnet;
use strict;
use warnings;
##############################################################################
my $telnet = new Net::Telnet( Timeout=>10, Errmode=>'die');
$telnet->open('192.168.2.5');
print "Esperando login\n";
$telnet->waitfor('/Login: $/i');
$telnet->print('admin');
print "Esperando pass\n";
$telnet->waitfor('/Password: $/i');
$telnet->print('mipass');
print "Esperando prompt\n";
$telnet->waitfor('/] >/i');
$telnet->print('interface wireless print');
my $output = $telnet->waitfor('/\$ $/i');
print $output;
But the system not recognize the prompt regular expression and script wait until time-out error:
Uncaught exception from user code:
pattern match timed-out at ./pruebamikro.pm line 29
at /usr/share/perl5/Net/Telnet.pm line 2036
Net::Telnet::_croak(‘Net::Telnet=GLOB(0x9b129b0)’, ‘pattern match timed-out’) called at /usr/share/perl5/Net/Telnet.pm line 539
I take the prompt regular expression from : http://arulgobi.blogspot.com/2010/04/mikrotik-backup-through-perl-script.html
2) I try access by PHP API : http://wiki.mikrotik.com/wiki/API_PHP_class
With simple code like this:
<?php
require('routeros_api.class.php');
$API = new routeros_api();
$API->debug = true;
if ($API->connect('192.168.2.5', 'admin', 'mipass')) {
$API->write('/interface print');
$READ = $API->read(false);
$ARRAY = $API->parse_response($READ);
print_r($ARRAY);
$API->disconnect();
}
?>
But return me this error:
Connection attempt #1 to 192.168.2.5:8291…
<<< [6] /login
PHP Notice: Undefined variable: _ in /home/p/Escritorio/enphp/routeros_api.class.php on line 304
PHP Notice: Undefined offset: 0 in /home/p/Escritorio/enphp/routeros_api.class.php on line 97
Connection attempt #2 to 192.168.2.5:8291…
Some help? Any experiences??
Thanks!