Community discussions

MikroTik App
 
User avatar
robmaltsystems
Forum Veteran
Forum Veteran
Topic Author
Posts: 707
Joined: Fri Jun 21, 2019 12:04 pm

Command aliases

Fri Aug 21, 2020 1:53 pm

Does RouterOS have command alias? I'm finding myself typing /log print where topics~"script" a lot so being able to alias it to say (ql) would be lovely.
 
User avatar
robmaltsystems
Forum Veteran
Forum Veteran
Topic Author
Posts: 707
Joined: Fri Jun 21, 2019 12:04 pm

Re: Command aliases

Fri Aug 21, 2020 1:55 pm

PS. On a similar subject, anyone help with the syntax for /log print to show just the last 15 mins? Or the last 10 lines of the log?
 
msatter
Forum Guru
Forum Guru
Posts: 2942
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Command aliases

Fri Aug 21, 2020 5:48 pm

:put [/log find time>([/system clock get time]-15m)];
This will show you the .id of the log-lines in the last 15 minutes but I am out on the moment to have the lines printed. Maybe someone else can do that or I will do that a later moment.
 
User avatar
robmaltsystems
Forum Veteran
Forum Veteran
Topic Author
Posts: 707
Joined: Fri Jun 21, 2019 12:04 pm

Re: Command aliases

Fri Aug 21, 2020 6:04 pm

That easy ;-) I was expecting some kind of DateAdd kind of function.. Thx!
 
msatter
Forum Guru
Forum Guru
Posts: 2942
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Command aliases

Fri Aug 21, 2020 9:31 pm

That easy ;-) I was expecting some kind of DateAdd kind of function.. Thx!
It was not that easy for me because the .id appeared not correct so I had a search and a peek at a other script:
viewtopic.php?f=9&t=151953&p=804911&hil ... et#p804911

My version now is compact and display the field requested it is buffered in array:
:foreach i in=[:toarray [/log find time>([/system clock get time]-15m)]] do={:put [/log get $i message ]};
display only the message
:foreach i in=[:toarray [/log find time>([/system clock get time]-15m)]] do={:put [/log get $i ]};
displays the lot

How did you solve the problem with the .id ?

Update: also filtering on the topics "script":
:foreach i in=[:toarray [/log find time>([/system clock get time]-15m) && topics~"script"]] do={:put [/log get $i message ]};
 
janeandr
just joined
Posts: 1
Joined: Sun Aug 23, 2020 10:04 pm

Re: Command aliases

Mon Sep 07, 2020 11:02 pm

Loos pretty simple
going to try it out
thanks
 
nbctcp
Frequent Visitor
Frequent Visitor
Posts: 77
Joined: Tue Sep 16, 2014 7:32 pm

Re: Command aliases

Fri Sep 25, 2020 11:40 pm

Does RouterOS have command alias? I'm finding myself typing /log print where topics~"script" a lot so being able to alias it to say (ql) would be lovely.
I also want this alias feature.
Seems can't find anywhere
I have automatic script that will send config to my email.
If I can alias "/system script run wrme" to wrme, it would be better
Hope added in the next release
 
msatter
Forum Guru
Forum Guru
Posts: 2942
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Command aliases

Sat Sep 26, 2020 12:31 am

:global domail do={/system script run wrme} on-error={log warning "Mail could not be send"};

$domail;

https://wiki.mikrotik.com/wiki/Manual:S ... #Functions
 
User avatar
Davis
Member Candidate
Member Candidate
Posts: 120
Joined: Mon Aug 01, 2011 12:27 pm
Location: Latvia, Riga
Contact:

Re: Command aliases

Wed Jan 08, 2025 12:58 am

To persist aliases between reboots the /system/scheduler can be used. E.g.:
/system/scheduler/add name=alias start-time=startup on-event=":global test1 do={:put \"You have ran \\\$test1 and it works.\"}"
And then after a reboot the "alias" $test1 is "registered".

Who is online

Users browsing this forum: No registered users and 27 guests