Community discussions

MikroTik App
 
User avatar
Jotne
Forum Guru
Forum Guru
Topic Author
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Need help with a script that fails on some routers

Sun Feb 11, 2024 9:42 pm

This is just part of a bigger script, but for some reason it starts to log error to the log when this part is run.

When cut/paste this to a terminal on a hex (750g3) router:
{
:local CmdHistory true
:local train [:tonum [:pick [/system resource get version] 0 1]] 

:if ($train > 6 and $CmdHistory) do={
:global cmd
:local f 0
:foreach i in=[/system history find] do={
:if ($i = $cmd) do={ :set f 1 }
:if ($f != 1) do={
:put "StartCMD"
:put [/system history get $i]
:put "EndCMD"
}
}
:global cmd  [:pick [/system history find] 0]
}
}
I get the error marked in red:
[admin@750] > {
{... :local CmdHistory true
{... :local train [:tonum [:pick [/system resource get version] 0 1]]
{...
{... :if ($train > 6 and $CmdHistory) do={
{{... :global cmd
{{... :local f 0
{{... :foreach i in=[/system history find] do={
{{{... :if ($i = $cmd) do={ :set f 1 }
{{{... :if ($f != 1) do={
{{{{... :put "StartCMD"
{{{{... :put [/system history get $i]
{{{{... :put "EndCMD"
{{{{... }
{{{... }
{{... :global cmd [:pick [/system history find] 0]
{{... }
{... }
interrupted
error - contact MikroTik support and send a supout file (10)

[admin@750] >
Even if this part give error message, rest of script runs fine. It may be a bug on one of my router.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3505
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: Need help with a script that fails on some routers

Sun Feb 11, 2024 10:15 pm

It works on 7.14beta8 on RB1100AHx4. It does not have a long history (4 records). But $cmd has a value at end without error and :put did there thing.

All my hEX-S run Dude+V6, so can't test it there. So if it's platform/version thing, IDK...
 
User avatar
Jotne
Forum Guru
Forum Guru
Topic Author
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Need help with a script that fails on some routers

Mon Feb 12, 2024 8:03 am

Strange thing that it only seems to be one router with problem.
RB951 with 17.3.3 works fine.
 
optio
Long time Member
Long time Member
Posts: 675
Joined: Mon Dec 26, 2022 2:57 pm

Re: Need help with a script that fails on some routers

Mon Feb 12, 2024 1:00 pm

Maybe is some memory stack issue with large history on that device... Regarding code, you can optimize loop using :while instead :foreach to iterate while condition $f!=1
 
User avatar
Jotne
Forum Guru
Forum Guru
Topic Author
Posts: 3300
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Need help with a script that fails on some routers

Sun Feb 18, 2024 9:28 am

All script error did go a way after upgrading from 7.13.3 to 7.13.4
 
eddieb
Member
Member
Posts: 327
Joined: Thu Aug 28, 2014 10:53 am
Location: Netherlands

Re: Need help with a script that fails on some routers

Tue Mar 26, 2024 8:59 am

Error still there in 7.14.1 ...
[eddieb@ccr1009] > /system/history/print 

error - contact MikroTik support and send a supout file (10)
It might indeed have something to do with the size of the history.
On my CCR there is a lot of history and it gives that error
On a HAPAX3 I had this error and a couple of hours later it was gone
SUP-148095 created

Who is online

Users browsing this forum: No registered users and 5 guests