Hi there,
I want to write a script like this
if ($myRouterHasWlan = true) {run this}
else {run that}
how can I make it in RouterOS?
Hi there,
I want to write a script like this
if ($myRouterHasWlan = true) {run this}
else {run that}
how can I make it in RouterOS?
Try this:
# Check that if we're using a wireless LAN
:if ($usewlan = "yes") do={
or this:
# Check that the WAN interface exists
:if ([/interface find name=$waninterface] = "") do={
{
local wlan [len [interface wireless find]]
if ($wlan>0) do={/system script run script1} else={/system script run script2}
}
change the name of script1 and script2 for your name of scripts
Thanks for you suggestions.
I’ve created a file named nuova.txt.
I’ve used
:if ($usewlan = "no") do={/file set nuova.txt contents="no wireless"}
and
{
local wlan [len [interface wireless find]]
if ($wlan<1) do={/file set nuova.txt contents="no wireless"}
}
but both of them don’t work. What’s wrong?
is working for me:
{
local wlan [len [interface wireless find]]
if ($wlan<1) do={/file set nuova.txt contents="no wireless"}
}
try this:
put [file get nuova.txt contents ]
remember first add a file:
file print file=nuova.txt
I’m using RouterOS 5.21 on a RB750GL.
Loot at the file attached. I’ve also inserted the line you suggested me.
It doesn’t work fo me.
I’ve tried without this line
put [file get nuova.txt contents ]
but nothing’s changing.
Look that, file already exists!
first paste in your terminal this
{
local wlan [len [interface wireless find]]
if ($wlan<1) do={/file set nuova.txt contents="no wireless"}
}
if the output is nothing, is all ok
and see the comment in the file with this
put [file get nuova.txt contents ]
GOT IT!
As my RB750GL doesn’t have wireless package enabled, “wireless” command does not will be recognized!
I’ve enabled the package and all is working fine!
Thanks!
if my answer helped you, please give me karma =)