A
A
Alkado2015-08-27 08:30:13
Mikrotik
Alkado, 2015-08-27 08:30:13

How to make a comparison by .id?

I created the following script for parsing logs...
(lines :put [/log get $sLasSta] and :put [/log get $sLasFin] are present for general understanding...):
{
:local sSta ("vpn-beeline: connecting ...")
:local sFin ("vpn-beeline: connected")
:local sDatSta ([/log find where message=$sSta])
:local sDatFin ([/log find where message=$sFin])
:local sLenSta ([:len $sDatSta])
:local sLenFin ([:len $sDatFin])
:local sLasSta ([:pick $sDatSta ($sLenSta - 1)])
:local sLasFin ([:pick $sDatFin ($sLenFin - 1 )])
:put $sLenSta
:put $sLenFin
:put $sLasSta
:put $sLasFin
:put [/log get $sLasSta]
:put [/log get $sLasFin]
:if ($sLasSta<$sLasFin) do={
:put Good}
}
It gives me:
1
1
*c
*f
.id=*c;buffer=memory;message=vpn-beeline: connecting...;time= 07:39:56;topics=l2tp;ppp;info
.id=*f;buffer=memory;message=vpn-beeline: connected;time=07:39:57;topics=l2tp;ppp;info
Script Error: cannot compare if array is less than array
So, why can't this bastard compare *c and *f (values ​​for .id=*c and .id=*f).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alkado, 2015-08-27
@Alkado

Solution found.
First we cut off *:
(:local sLasStaNorm [:pick $sLasSta 1 [:len $sLasSta]])
then turn the resulting string into hexadecimal format by simply adding 0x to the beginning:
("0x$sLasStaNorm")
after these manipulations, everything starts fine be compared.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question