Community discussions

User avatar
just joined
Topic Author
Posts: 19
Joined: Tue Jul 24, 2012 10:53 am
Reputation: 3

Prompting user from terminal in a Script.

Tue Nov 13, 2012 12:51 pm

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 -> viewtopic.php?f=9&t=38683#p284764
Second one (The y/n post) -> viewtopic.php?f=9&t=41042#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")
:put "You entered: $mktiden";
/system identity set name=$mktiden;
Katsuro Kurosaki
If you ask for a banana, would you expect someone to hand you an orange? Or a fork? No you wouldn't, because you asked for a banana, and you expect them to understand that a banana is not an orange or a fork. It's the same principle.

Who is online

Users browsing this forum: No registered users and 3 guests