Community discussions

MUM Europe 2020
 
dennis46
just joined
Topic Author
Posts: 2
Joined: Thu May 31, 2018 3:10 pm

Script input from console ... works!

Thu May 31, 2018 3:18 pm

I found an instresting undocumented (?) solution to input values from terminal to script.

It looks like this.

=== sample script ===
:local input do={:put $1;:return}
:local login [$input "Enter login"]
:local password [$input "Enter password"]
:put "Login is [$login] and password is [$password]"
=================

=== terminal outeput ===
[admin@MikroTik AP] /ppp secret> /system script run 1
Enter login
value: mike
Enter password
value: jdajshdjadh
Login is [mike] and password is [jdajshdjadh]
[admin@MikroTik AP] /ppp secret>
====================

So if you use :return without any params you get input from terminal.

No mention of this behaviour found at https://wiki.mikrotik.com/wiki/Manual:Scripting and https://wiki.mikrotik.com/wiki/Manual:S ... g-examples ...
 
User avatar
dasiu
Trainer
Trainer
Posts: 232
Joined: Fri Jan 30, 2009 11:41 am
Location: Reading, UK
Contact:

Re: Script input from console ... works!

Mon Jun 04, 2018 12:37 pm

dennis46 - it's a nice lifehack!! Thanks! :)

It's not "Undocumented" and it's probably not a "feature" :). MikroTik does that if you don't fill a required value. Try: /ping - it will ask you for address (as it's a required argument). The same when you want to remove something (/ip address remove), not specifying what - it'll ask you for clarification. And does the same here. Probably noone thought that this "asking for clarification" can be used here that way :D.
 
dennis46
just joined
Topic Author
Posts: 2
Joined: Thu May 31, 2018 3:10 pm

Re: Script input from console ... works!

Wed Jun 06, 2018 3:04 pm

It's not "Undocumented" and it's probably not a "feature" . MikroTik does that if you don't fill a required value.
Ok! Thanks for explanation! :-)

Who is online

Users browsing this forum: No registered users and 28 guests