Community discussions

 
User avatar
Davis
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 64
Joined: Mon Aug 01, 2011 12:27 pm
Location: Latvia, Riga
Contact:

Reading log on ROS 6.2/6.3

Mon Sep 09, 2013 12:15 pm

How to read log on RouterOS 6.2+?
Till ROS 6.1 (including) the following code worked:
{
:global a ""
:foreach le in=[/log print as-value] do={
:set a "$a$[:tostr [:pick $le 3]]\r\n"
}
:put $a
}
But starting with 6.2 it just outputs many empty lines.
Is this a bug or log should be retrieved otherwise?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Reading log on ROS 6.2/6.3

Mon Sep 09, 2013 1:03 pm

on 6.4rc1 I get log entry topics. If that is what you require, then this will work this way in 6.4
 
User avatar
Davis
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 64
Joined: Mon Aug 01, 2011 12:27 pm
Location: Latvia, Riga
Contact:

Re: Reading log on ROS 6.2/6.3

Mon Sep 09, 2013 2:12 pm

on 6.4rc1 I get log entry topics. If that is what you require, then this will work this way in 6.4
Great! Thanks! Then it's fixed in 6.4 :)
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5913
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Reading log on ROS 6.2/6.3

Mon Sep 09, 2013 2:34 pm

Correct script would be:

ros code

{
  :global a ""
  :foreach le in=[/log print as-value] do={
    :set a ($a . [:tostr [($le->"time")]] . "\r\n")
  }
  :put $a
}
It is wiser to use the name of element to get the value since order of the elements may change.
 
User avatar
Davis
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 64
Joined: Mon Aug 01, 2011 12:27 pm
Location: Latvia, Riga
Contact:

Re: Reading log on ROS 6.2/6.3

Tue Sep 17, 2013 2:09 pm

Correct script would be:

ros code

{
  :global a ""
  :foreach le in=[/log print as-value] do={
    :set a ($a . [:tostr [$le->"time"]] . "\r\n")
  }
  :put $a
}
It is wiser to use the name of element to get the value since order of the elements may change.
Thanks! But looks like this code fragment doesn't work...

ros code

[demo@demo.mt.lv] > {
{...   :global a ""
{...   :foreach le in=[/log print as-value] do={
{{...     :set a ($a . [:tostr [$le->"time"]] . "\r\n")
syntax error (line 4 column 30)
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5913
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Reading log on ROS 6.2/6.3

Tue Sep 17, 2013 2:42 pm

ros code

:set a ($a . [:tostr [($le->"time")]] . "\r\n")
 
User avatar
Davis
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 64
Joined: Mon Aug 01, 2011 12:27 pm
Location: Latvia, Riga
Contact:

Re: Reading log on ROS 6.2/6.3

Sun Sep 22, 2013 6:09 pm

ros code

:set a ($a . [:tostr [($le->"time")]] . "\r\n")
Thanks for helping to improve my script Send email about reboot.

Who is online

Users browsing this forum: No registered users and 11 guests