Community discussions

 
Stril
Member Candidate
Member Candidate
Topic Author
Posts: 116
Joined: Fri Nov 12, 2010 7:18 pm

Exit script if...

Wed Aug 29, 2018 4:50 pm

Hi!

I am looking for a solution to abort a script if a variable is empty.
:if ([:len $net1] = 0) do={
exit
}
...rest of the script should not be executed if $net1 empty
This does not work. Can you give me a hint on how to solve this?

Thank you
Stril
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 1715
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: Exit script if...

Wed Aug 29, 2018 4:55 pm

Maybe this could help:
:if ([:len $net1] > 0) do={
do what I want
}
Real admins use real keyboards.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5931
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Exit script if...

Wed Aug 29, 2018 5:49 pm

/quit
 
User avatar
ADahi
Member Candidate
Member Candidate
Posts: 217
Joined: Thu Sep 21, 2017 7:16 pm
Location: Iraq, Ninavah
Contact:

Re: Exit script if...

Thu Aug 30, 2018 3:26 pm

Hi!

I am looking for a solution to abort a script if a variable is empty.
:if ([:len $net1] = 0) do={
exit
}
...rest of the script should not be executed if $net1 empty
This does not work. Can you give me a hint on how to solve this?

Thank you
Stril
try reverse condition
:if ([:len $net1]!=0) do={
execute
}
 
User avatar
eworm
Member
Member
Posts: 390
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Exit script if...

Fri Aug 31, 2018 5:56 pm

/quit
That closes the terminal connection...

I'd suggest
:error "bye!"
Manage RouterOS scripts and extend your devices' functionality: RouterOS Scripts

Who is online

Users browsing this forum: No registered users and 3 guests