Page 1 of 1

Prompting user from terminal in a Script.

Posted: Tue Nov 13, 2012 11:51 am
by KatsuroKurosaki
Good day everyone,

I would like to ask about the scripts I found in this forum, to prompt the user to type characters:
First one -> http://forum.mikrotik.com/viewtopic.php ... 83#p284764
Second one (The y/n post) -> http://forum.mikrotik.com/viewtopic.php ... 42#p203961

I am doing a script who asks the user for a new Mikrotik Identity (At the end it will be an Auto-Setup script for our Network admins), but it doesn't store the value in the variable (Or this is what I think, you will know why later); so the Mikrotik Identity doesn't change.
The Policy (Permissions) of scripts are all enabled (Must fix in final version). First created the Prompt script, it's content is the exact as the First one link I posted above. Then, created a second one, named Setup, copied and adapted the content of the examples of use.
The script runs fine, but the Mikrotik Identity doesn't change. Saying that I typed an empty identity string, the [:put $mktiden] returns an empty string, but at System > Scripts > Environment I can see the name of the variable and it's value, the one I typed.

I'm wondering what's happening here; little help will be apreciated. I'm running RouterOS 5.19 on a RB450G. The code:
:global Prompt;
:local runFunc;
/system script run Prompt

:put "Auto-Installation script";
:put " ";

# Prompt for Mikrotik Identity
    :local mktiden;
    :set runFunc [:parse (":global mktiden;" . \
             ":local input \"Mikrotik Identity? :\";" . \
                       $Prompt . \
             ":set mktiden \$output")
         ]
       
    $runFunc;
:put "You entered: $mktiden";
/system identity set name=$mktiden;