Community discussions

MikroTik App
 
verymuch
just joined
Topic Author
Posts: 5
Joined: Sun Mar 22, 2009 12:49 am

expected end of command

Thu Apr 14, 2011 10:56 pm

hello all
I need help in command
:if ($result = 1) do={ip route set [find comment="DEFAULT ROUTE"] gateway=$gateway1}
tells me expected end of command (line 1 column 49)
whats wrong?
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: expected end of command

Thu Apr 14, 2011 11:01 pm

Wrong scope. Your find command is being executed in whatever context you're currently in, not the context of "/ip route". At the level where you're executing 'comment' is not a valid field to find, hence a parsing error. It it also ALWAYS best practice to preface all scope with a "/" so it starts at the command root.

Here two options:
:if ($result = 1) do={ /ip route set  [/ip route find comment="DEFAULT ROUTE" ] gateway=$gateway1 }
:if ($result = 1) do={ /ip route { set [ find comment="DEFAULT ROUTE" ] gateway=$gateway1 } }
 
verymuch
just joined
Topic Author
Posts: 5
Joined: Sun Mar 22, 2009 12:49 am

Re: expected end of command

Thu Apr 14, 2011 11:05 pm

thanks
 
aonallah
just joined
Posts: 6
Joined: Thu Sep 11, 2014 2:22 am

Re: expected end of command

Sat Jan 17, 2015 4:16 am

hiii
I have the same problem when use SSH from c# App in this code ......

/system script add name="ExpireHotspotUsers" source="
# By aonallah1987@yahoo.com & fb.com/aonallah1
# Run this daily
:foreach i in=[/ip hotspot user find] do={
:global startbytess [/ip hotspot user get $i bytes-out]
:global allvalcomment [/ip hotspot user get $i comment]
:global typee [:typeof $allvalcomment]
:global lennn [:len $allvalcomment]
:if ( $lennn < 5 ) do={
:if (startbytess > 0 ) do={
:if ($allvalcomment = 1 || $allvalcomment < 1 ) do={
/ip hotspot user disable $i
/ip hotspot user set $i comment=(($allvalcomment))
} else {
/ip hotspot user set $i comment=(($allvalcomment-1))
}
}}
else {
:if ( $lennn >= 4) do={
:global valcomment [:pick ($allvalcomment) [:find ($allvalcomment) " " -1] 100 ]
:global realcomment [:pick ($allvalcomment) 0 [:find ($allvalcomment) " " -1]]
:if ($startbytess > 0 ) do={
:if ($realcomment = 1 || $realcomment < 1 ) do={
/ip hotspot user disable $i
/ip hotspot user set $i comment=(($realcomment). $valcomment)
} else {
/ip hotspot user set $i comment=(($realcomment-1). $valcomment)
}
}
}}}
"




--------------------------
hellp