Hi,
How do I convert the uptime output from 1d12:28:40 to seconds?
Is there a command in RouterOS for processing delimiters, i.e., "cut -d:" and "awk -F':'" in shell script?
Thanks.
I can try to write something if I get a chance later... but the basic idea is use :pick to break it up into its pieces and then convert them to numbers and multiply it all together....maybe :pick could be useful.
I can try to write something if I get a chance later... but the basic idea is use :pick to break it up into its pieces and then convert them to numbers and multiply it all together....maybe :pick could be useful.
:local myString "1d:12:00:00" :local days [:pick $myString (0 [:find $myString "d"])] :set myString [:pick $myString ([:find $myString "d"]+2) [:len $myString]] :local hours [:pick $myString (0 [:find $myString ":"])] :set myString [:pick $myString ([:find $myString ":"]+1) [:len $myString]] :local minutes [:pick $myString (0 [:find $myString ":"])] :set myString [:pick $myString ([:find $myString ":"]+1) [:len $myString]] :local seconds $myStringOr something like that.
If "myString" was "1d:12:00:00", it above script worked great. However, if "myString" was "12:34:56", the variable "days" would return 1 as well. I am using RouterOS v6.7.I can try to write something if I get a chance later... but the basic idea is use :pick to break it up into its pieces and then convert them to numbers and multiply it all together....maybe :pick could be useful.ros code
:local myString "1d:12:00:00" :local days [:pick $myString (0 [:find $myString "d"])] :set myString [:pick $myString ([:find $myString "d"]+2) [:len $myString]] :local hours [:pick $myString (0 [:find $myString ":"])] :set myString [:pick $myString ([:find $myString ":"]+1) [:len $myString]] :local minutes [:pick $myString (0 [:find $myString ":"])] :set myString [:pick $myString ([:find $myString ":"]+1) [:len $myString]] :local seconds $myStringOr something like that.
Thanks efaden!You'll have to insert an if statement then to account due the variability.
Sent from my SCH-I545 using Tapatalk