Estou tentando obter detalhes do túnel IPSec do roteador. Depois disso busque linhas com endereços IP.
Então, eu tenho o seguinte código:
send "show tunnel ipsec remote 10.10.10.10\r"
expect "local"
send "\r"
set outcome $expect_out(buffer)
set records [split $outcome "\n"]
foreach rec $records {
if {[regexp {\*.*$} $rec tunnel_name]} {
regsub -all "\r" $tunnel_name "" tunnel_name
regsub -all " " $tunnel_name "" tunnel_name
set NodeBInfo "Tunnel:\t $tunnel_name"
set command "show tunnel ipsec name $tunnel_name detail | include \"Remote IP\""
send "$command\r"
expect "local"
set outcome1 $expect_out(buffer)
set records1 [split $outcome1 "\n"]
foreach rec1 $records1 {
if {[regexp {Remote IP :.*$} $rec1 remote_ip]} {
regsub -all "\r" $remote_ip "" remote_ip
append NodeBInfo "\t$remote_ip"
}
}
unset outcome1
unset command
set command "show tunnel ipsec name $tunnel_name detail | include \"IRAC IP\""
send "$command\r"
expect "local"
set outcome2 $expect_out(buffer)
set records2 [split $outcome2 "\n"]
foreach rec2 $records2 {
if {[regexp {IRAC IP:.*$} $rec2 remote_ip2]} {
regsub -all "\r" $remote_ip "" remote_ip2
append NodeBInfo "\t$remote_ip2"
}
}
unset outcome2
unset command
puts "NodeBInfo $NodeBInfo\r"
}
}
Eu esperava o seguinte valor da variável NodeBInfo:
NodeBInfo Tunnel: *ran_tunnel-10.10.10.10-4049 Remote IP : 10.10.10.10 Local IP : 20.20.20.20 IRAC IP: 40.40.40.40 / 255.255.255.0
Mas eu só tenho:
NodeBInfo Tunnel: *ran_tunnel-10.10.10.10-4049
Saída completa do script:
[local]Router#show tunnel ipsec remote 10.10.10.10
::::: Tunnel : *ran_tunnel-10.10.10.10-4049
Key : -
Remote IP : 10.10.10.10 Local IP : 20.20.20.20
Tnl Type : IPsec ASP Slot/Id : 6/1
State : Up Bound to : ipsec_traffic_ran_mb@iub_seg
Circuit ID: 12479 Internal Hdl: 255/32:511:63:31/0/2/12479
::::: Tunnel : *oam_tunnel-10.10.10.10-4bca
Key : -
Remote IP : 10.10.10.10 Local IP : 30.30.30.30
Tnl Type : IPsec ASP Slot/Id : 6/1
State : Up Bound to : ipsec_traffic_mb@om_seg
Circuit ID: 15340 Internal Hdl: 255/32:511:63:31/0/2/15340
[local]Router#
[local]Router#show tunnel ipsec name *ran_tunnel-10.10.10.10-4049 detail | include "Remote IP"
Remote IP : 10.10.10.10 Local IP : 20.20.20.20
[local]Router#NodeBInfo Tunnel: *ran_tunnel-10.10.10.10-4049
show tunnel ipsec name *ran_tunnel-10.10.10.10-4049 detail | include "IRAC IP"
IRAC IP: 40.40.40.40 / 255.255.255.0
[local]Router#show tunnel ipsec name *oam_tunnel-10.10.10.10-4bca detail | include "Remote IP"
Remote IP : 10.10.10.10 Local IP : 30.30.30.30
[local]Router#NodeBInfo Tunnel: *oam_tunnel-10.10.10.10-4bca
show tunnel ipsec name *oam_tunnel-10.10.10.10-4bca detail | include "IRAC IP"
IRAC IP: 50.50.50.50 / 255.255.255.0
[local]Router#
[local]Router#exit