script?

I want to make a script which tells me identity of the routerboard and signal strength of station:

:global identity;
:global SSL;

:set identity [/system identity get name];
:put $identity;
:set SSL [/interface wireless registration-table get signal-strength];
:put $SSL;

but I get the identity correct and for signal strength it says invalid item number.

Where am I wrong?

Thank you

because you have to specify from which item to get signal strength

/interface wireless registration-table get [id] signal-strength

But when I put /interface wireless registration-table get [0] signal-strength it says bad command name 0… :confused: I am little confused…help me a little bit more :wink:

You can’t use id numbers printed from console, ID is internal identification number that is returned by find command. So basically you have to find an item and then get it’s parameters.

Please read scripting manual before writing any script
http://wiki.mikrotik.com/wiki/Scripting
then look at scripting examples
http://wiki.mikrotik.com/wiki/Scripting-examples

:global identity;
:global SSL;

:set identity [/system identity get name];
:put $identity;
:set SSL [/interface wireless registration-table get [/interface wireless registration-table find signal-strength] signal-strength];
:put $SSL;

But I still get invalid item number :confused:

That’s because your find command is incorrect and invalid - you need to give it parameters to find items by. I don’t have any devices with wireless interfaces, so here an example of fetching the MTU of an ethernet interface:

:put [/interface ethernet get [/interface ethernet find name="ether1"] mtu]

Though you can use numeric indices in scripts, you just must not enclose them in square brackets, as square brackets indicate commands. I believe you initially tried:

:put /interface wireless registration-table get [0] signal-strength

Try this instead:

put /interface wireless registration-table get 0 signal-strength

Of course you’re still better off learning how to retrieve items via find as you won’t always be able to rely on hard-coding an ID.

This is the parameters that I want to display with mu script:

I have success in displaying all other parameters except signal-strength and uptime. Does anyone has a code line for this?
parameters.JPG

I am sorry for annoyance, but yesterday this wasn’t working…today the sam code works:

:global identity;
:global SSL;

:set identity [/system identity get name];
:put $identity;
:set SSL [/interface wireless registration-table get [/interface wireless registration-table find interface="wlan1"] signal-strength];
:put $SSL;

It works…thanks anyway :slight_smile: :smiley:

if find will return more than one match then your script will not work.