[Resolved] ROS Script have “like” ?

SQL 2000 :

select * from ab  where    name like "ite"

Get all like "ite " records







ROS 3.30

print where name like "AN"



It’s error,


so , ROS 3.30, How to write The correct code




thank you

tell us what exactly you want to do, not compare it to SQL :slight_smile:

There is no such command as “like” in RouterOS.
To get list of available commands refer to scripting documentation.

In your particular example you can use regexps to match strings

print where name~“AN”

thank you,



Your answer is what I want




very very Thanks,



I am from chinese, I do not speak English,


use google,



thank you.

By Google Translate

He used to find active ADSL lines

Modified PCC

zh-cn
http://bbs.routerclub.com/forum.php?mod=viewthread&tid=48635&extra=page%3D1%26filter%3Dauthor%26orderby%3Ddateline%26orderby%3Ddateline



SORRY, I also found a problem of regular expression



How do I distinguish

/1
/11
/12

find per-connection-classifier~(“/1”) It is wrong.




Help ME

[admin@rb433] /ip firewall mangle> print where per-connection-classifier~"/1"
Flags: X - disabled, I - invalid, D - dynamic 
 0   chain=test action=accept per-connection-classifier=both-addresses:1/1 
 1   chain=test action=accept per-connection-classifier=both-addresses:11/11 
 2   chain=test action=accept per-connection-classifier=both-addresses:12/12 

[admin@rb433] /ip firewall mangle> print where per-connection-classifier~"/11"
Flags: X - disabled, I - invalid, D - dynamic 
 1   chain=test action=accept per-connection-classifier=both-addresses:11/11 

[admin@rb433] /ip firewall mangle> print where per-connection-classifier~"/11\$"
Flags: X - disabled, I - invalid, D - dynamic 
 1   chain=test action=accept per-connection-classifier=both-addresses:11/11 

[admin@rb433] /ip firewall mangle> print where per-connection-classifier~"/12" 
Flags: X - disabled, I - invalid, D - dynamic 
 2   chain=test action=accept per-connection-classifier=both-addresses:12/12

[admin@rb433] /ip firewall mangle> print where per-connection-classifier~"/12\$"
Flags: X - disabled, I - invalid, D - dynamic 
 2   chain=test action=accept per-connection-classifier=both-addresses:12/12 

[admin@rb433] /ip firewall mangle> print where per-connection-classifier~"/1"   
Flags: X - disabled, I - invalid, D - dynamic 
 0   chain=test action=accept per-connection-classifier=both-addresses:1/1 
 1   chain=test action=accept per-connection-classifier=both-addresses:11/11 
 2   chain=test action=accept per-connection-classifier=both-addresses:12/12 

[admin@rb433] /ip firewall mangle> print where per-connection-classifier~"/1\$" 
Flags: X - disabled, I - invalid, D - dynamic 
 0   chain=test action=accept per-connection-classifier=both-addresses:1/1 
[admin@rb433] /ip firewall mangle>

It’s normal regex rules - $ matches the end of a term. Hope that helps. If not - got some more details? Your question as is doesn’t make a whole lot of sense. Maybe show the rules you have, and explain which ones you’re trying to match?








thank you , my script is OK



PCC auto change


{
	:local pppoeclientAllNum
	:local pppoeclientRunNum
	:local pppoeclientName
	:local z 0
	:set pppoeclientAllNum [:len [/interface pppoe-client find ]]
	:log info ("pppoeclientAllNum".$pppoeclientAllNum)
	:set pppoeclientRunNum [:len [/interface pppoe-client find running=yes]]
	:log info ("pppoeclientRunNum".$pppoeclientRunNum)

	:if ($pppoeclientRunNum < $pppoeclientAllNum) do={
		:for ii from=0 to=($pppoeclientAllNum-1) do={
			:log info $ii
			:if ($ii<=($pppoeclientRunNum-1)) do={
				/ip firewall mangle set [find per-connection-classifier~("/".$ii."\$")] per-connection-classifier=("both-addresses:".$pppoeclientRunNum."/".$ii) comment=("PCC" . $pppoeclientRunNum . "-" . $ii) disable=no 
				/ip firewall mangle set [find action="mark-routing" connection-mark=[/ip firewall mangle get [find per-connection-classifier~("/".$ii."\$")] new-connection-mark ]] disable=no
				:log warning ("both-addresses:".$pppoeclientRunNum."/".$ii)
			} else={
				/ip firewall mangle set [find per-connection-classifier~("/".$ii."\$")] disable=yes
				/ip firewall mangle set [find action="mark-routing" connection-mark=[/ip firewall mangle get [find per-connection-classifier~("/".$ii."\$")] new-connection-mark ]] disable=yes
				:log warning ("both-addresses:".$pppoeclientAllNum."/".$ii."disable") 
			}
		}
	}
	:if ($pppoeclientRunNum = $pppoeclientAllNum) do={
		:set z [:len [/ip firewall mangle find action="mark-connection" disabled=yes chain=prerouting]]
		:log info $z
		:if ($z>0) do={
			:for ii from=0 to=($pppoeclientRunNum-1) do={
				/ip firewall mangle set [find per-connection-classifier~("/".$ii."\$")] per-connection-classifier=("both-addresses:".$pppoeclientRunNum."/".$ii) comment=("PCC" . $pppoeclientRunNum . "-" . $ii) disable=no 
				/ip firewall mangle set [find action="mark-routing" connection-mark=[/ip firewall mangle get [find per-connection-classifier~("/".$ii."\$")] new-connection-mark ]] disable=no
				:log warning ("both-addresses:".$pppoeclientRunNum."/".$ii)
			}
		}
	}
}