I’m making an ‘install script’ to install another script on routerboards. Currently it’s setup as a function, and the user can pass arguments to the function.
Is there any way for a script to ask for user input via the console? E.G
There’s the “/terminal inkey” command, which asks the user for a single key, and returns the key code of the pressed key, which you can then decode into an ASCII character or a keyboard key.
It’s as cumbersome to work with as it sounds… You need to invoke it as many times as the number of characters you need, or more precisely, keep invoking it until a new line is entered (character code 13). Oh, and you better support backspace (character code 8 ) too. If you manage to elegantly abstract away such stuff, you may as well create a function for that… One which wouldn’t need prompts upon its install . But at that point, I think we can agree that’s overkill.
I’m trying to make a initial configuration script and need to parse user input to set router name, WAN ip and GW, local ip and GW and so on…
When I’m trying to use
# function to prompt user to enter a value
:global read do={:return}
# storing the value entered by the user
:local userinput [$read]
put $read
showing me “;(eval (eval /return))” as answer
What I’m doing wrong?
FW from 6.39 up to 6.42.3.
This is a 6.47.10 working example: (not tested on other versions)
{
:local readinput do={:return}
:put "\r\nInsert a string you want use as"
:local input [$readinput]
:put "\r\nYou have insert: $input"
:put "Which is a $[:typeof $input]\r\n"
}