Community discussions

MikroTik App
 
cicserver
Member
Member
Topic Author
Posts: 303
Joined: Sun Jul 24, 2011 12:04 pm

[SOLVED] FIND with WILDCARD syntax HELP required

Fri Feb 21, 2014 7:56 am

Greetings,

I wan to print (:log info) all hotspot users account who DO NOT have word "special" in comments.

For example, Currently users have following comments:
user1 = special library
user2 = special xyz garden
user3 = 123 special lobby
user4 = ordinary single
user5 = double ordinary

Now I want to print only users name who DONOT have special in there comments section.
I am trying with this with no luck :(
:local username
:foreach i in=[/ip hotspot user find] do {
:set username ( username [ip hotspot user get $i name])
:if ([/ip hotspot user get [/ip hotspot user find name=$username] comment ] ~"special") do {
:log warning "$username..."
}}}}}
The above script print users who have "special" in there comments, but I want opposite of it, i want to print name of users who donot have word"special" in the comments.
howto correct?
Last edited by cicserver on Mon Feb 24, 2014 12:39 pm, edited 1 time in total.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7186
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: FIND with WILDCARD syntax HELP required

Fri Feb 21, 2014 12:49 pm

print where !(name~"special")
 
User avatar
skot
Long time Member
Long time Member
Posts: 584
Joined: Wed Nov 30, 2011 3:05 am

Re: FIND with WILDCARD syntax HELP required

Fri Feb 21, 2014 6:52 pm

print where !(name~"special")
I couldn't get :if !() to work, it just gives syntax errors.
Greetings,

I wan to print (:log info) all hotspot users account who DO NOT have word "special" in comments.

For example, Currently users have following comments:
user1 = special library
user2 = special xyz garden
user3 = 123 special lobby
user4 = ordinary single
user5 = double ordinary

Now I want to print only users name who DONOT have special in there comments section.
I am trying with this with no luck :(
:local username
:foreach i in=[/ip hotspot user find] do {
:set username ( username [ip hotspot user get $i name])
:if ([/ip hotspot user get [/ip hotspot user find name=$username] comment ] ~"special") do {
:log warning "$username..."
}}}}}
The above script print users who have "special" in there comments, but I want opposite of it, i want to print name of users who donot have word"special" in the comments.
howto correct?
You could simply use else{}, something like this:

ros code

/ip hotspot user

:foreach i in=[find] do={
  :local username [get $i name]
  :if ([get $i comment]~"special") do={
  } else={
    :log warning "$username..."
  }
}
 
cicserver
Member
Member
Topic Author
Posts: 303
Joined: Sun Jul 24, 2011 12:04 pm

Re: FIND with WILDCARD syntax HELP required [SOLVED]

Mon Feb 24, 2014 6:54 am

Thanks Mr. Scot & mrz,

I tried Scot method and it worked like a charm :D
Solved !

Who is online

Users browsing this forum: No registered users and 8 guests