Estoy haciendo una conexión vía telnet donde me conecto a una maquina y se le ingresa un comando querydmc id
en donde id= es un numero
, este proceso se va ejecutando 14 veces por ende va desde el 1 al 14
cada recorrido obtiene información diferente, adjunto 3 ejemplo de como es el resultado:
querydmc 1
Unit: DMC 1
Primary State: IS
Secondary State:
FW Load in RAM: DDM50AK01
FW Load in FLASH A: DDM50AK01
FW Load in FLASH B: DDM50AK01
Circuit Pack: NTBN19EA
Serial Number: FL000MF
Manufacturer's Date: 06/JUN/2004
Modem: 1 Primary State: IS Secondary State:
DS CP: 5 Spectrum_Chan_Code: 1559
US CP: 32 Spectrum_Chan_Code: 80
TX LEVEL: 50 dBmV RX LEVEL: 15 dBmV
Modem: 2 Primary State: IS Secondary State:
DS CP: 9 Spectrum_Chan_Code: 1551
US CP: 6 Spectrum_Chan_Code: 80
TX LEVEL: 50 dBmV RX LEVEL: 8 dBmV
querydmc 2
Unit: DMC 2
Primary State: IS
Secondary State:
FW Load in RAM: DDM20BM01
FW Load in FLASH A: DDM20BM01
FW Load in FLASH B: DDM20BM01
Circuit Pack: NTBN19CA
Serial Number: WZ16REZ
Manufacturer's Date: 27/NOV/2000
Modem: 1 Primary State: IS Secondary State:
DS CP: 1 Spectrum_Chan_Code: 1503
US CP: 18 Spectrum_Chan_Code: 94
TX LEVEL: 51 dBmV RX LEVEL: 20 dBmV
Modem: 2 Primary State: IS Secondary State:
DS CP: 1 Spectrum_Chan_Code: 1535
US CP: 16 Spectrum_Chan_Code: 80
TX LEVEL: 51 dBmV RX LEVEL: 7 dBmV
querydmc 3
Unit: DMC 3
Primary State: IS
Secondary State:
FW Load in RAM: DDM20BM01
FW Load in FLASH A: DDM20BM01
FW Load in FLASH B: DDM20BM01
Circuit Pack: NTBN19AA
Serial Number: Z1A3BYM
Manufacturer's Date: 22/JAN/1997
Modem: 1 Primary State: IS Secondary State:
DS CP: 11 Spectrum_Chan_Code: 1551
US CP: 36 Spectrum_Chan_Code: 94
TX LEVEL: 50 dBmV RX LEVEL: 15 dBmV
Modem: 2 Primary State: IS Secondary State:
DS CP: 13 Spectrum_Chan_Code: 1551
US CP: 38 Spectrum_Chan_Code: 80
TX LEVEL: 50 dBmV RX LEVEL: 5 dBmV
NOTA: Puede que un querydmc id
no traiga ninguna información el resultado es el siguiente:
>querydmc 4
Specified DMC does not exist.
Lo que he probado:
DMC: for my $dmc (1..14)
{
$t->print("querydmc $dmc");
my ($pmatch, $match) = $t->waitfor (
Match => '/>$/'
, Timeout => $timeout*3 );
my $modemReached = 0;
for my $line (split "\r", $pmatch)
{
$line =~ s/\s*\n$//;
if ($line =~ /^Modem:\s+([0-9]+)\s+(.*)/ || $modemReached > 0) {
my $modem = $1;
my $subtitle = $modem ? $2 : $line;
if ($subtitle =~ /^([^:]+):\s+(\S+( dBmV)?)\s+([^:]+):(.*)/)
{
my $key1 = $1;
my $value1 = $2;
my $key2 = $4;
my $value2 = $5;
print "$modem\n";
print "$key1: $value1\n";
print "$key2: $value2\n";
}
$modemReached = 1;
}
else {
my ($key, $value) = split /:/, $line;
print "$key => $value\n";
}
}
}
La respuesta que obtengo:
querydmc 1 =>
Unit => DMC 1
Primary State => IS
Secondary State =>
FW Load in RAM => DDM20BM01
FW Load in FLASH A => DDM20BM01
FW Load in FLASH B => DDM20BM01
Circuit Pack => NTBN19AA
Serial Number => R1AGX1W
Manufacturer's Date => 13/AUG/1998
1
Primary State: IS
Secondary State:
DS CP: 1
Spectrum_Chan_Code: 1535
US CP: 2
Spectrum_Chan_Code: 80
TX LEVEL: 50 dBmV
RX LEVEL: 15 dBmV
2
Primary State: IS
Secondary State:
DS CP: 1
Spectrum_Chan_Code: 1559
US CP: 2
Spectrum_Chan_Code: 94
TX LEVEL: 50 dBmV
RX LEVEL: 8 dBmV
Lo que deseo obtener para guardar en la base de datos:
MODEM | KEY | VALUE
null Unit DMC 1
null Primary State IS
null Secondary State
null FW Load in RAM DDM20BM01
null FW Load in FLASH A DDM20BM01
null FW Load in FLASH B DDM20BM01
null Circuit Pack NTBN19AA
null Serial Number R1AGX1W
null Manufacturer's Date 13/AUG/1998
1 Primary State IS
1 Secondary State
1 DS CP 1
1 Spectrum_Chan_Code 1535
1 US CP 2
1 Spectrum_Chan_Code 80
1 TX LEVEL 50 dBmV
1 RX LEVEL 15 dBmV
2 Primary State IS
2 Secondary State
2 DS CP 1
2 Spectrum_Chan_Code 1559
2 US CP 2
2 Spectrum_Chan_Code 94
2 TX LEVEL 50 dBmV
2 RX LEVEL 8 dBmV