It is currently October 18th, 2024, 9:20 am

IfMatch IP Address and Reserved Characters

Get help with installing and using Rainmeter.
User avatar
cwfrizzell
Posts: 80
Joined: August 10th, 2009, 9:03 pm

IfMatch IP Address and Reserved Characters

Post by cwfrizzell »

I have a meter that checks the IP address and supplies a corresponding text string based on it.

NOTE: IP address numbers purposely removed below for forum purposes only

Code: Select all

[mIP]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=Best
UpdateDivider=5
DynamicVariables=1
IfMatch=XXX.XXX.X.XXX|YYY.YYY.Y.YYY 		
IfMatchAction=[!SetOption IPMeter Text "HOME"]
IfNotMatchAction=[!SetOption IPMeter Text "AWAY!"]
IfMatchMode=1
The IfMatchAction does not work correctly with two IP addresses listed, separated by |

As I understand it, the problem may be the reserved character . that may have to be escaped

How can I make this work properly?
Cheers!

Chuck
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5543
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IfMatch IP Address and Reserved Characters

Post by eclectic-tech »

Yes, the period is a reserved character and needs to be escaped.
Manual wrote:Reserved characters in regular expression, which are . ^ $ * + ? ( ) [ { \ | must be escaped with the \ character when used as a literal in the IfMatch option.
This should work to set the correct option when using "OR" match test:

Code: Select all

[mIP]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=Best
UpdateDivider=5
DynamicVariables=1
IfMatch=XXX\.XXX\.X\.XXX|YYY\.YYY\.Y\.YYY
IfMatchAction=[!SetOption IPMeter Text "HOME"]
IfNotMatchAction=[!SetOption IPMeter Text "AWAY!"]
IfMatchMode=1

[IPMeter]
Meter=String
Text=
FontColor=255,255,255
User avatar
cwfrizzell
Posts: 80
Joined: August 10th, 2009, 9:03 pm

Re: IfMatch IP Address and Reserved Characters

Post by cwfrizzell »

Thanks for the response. Unfortunately, it did not work. The meter continues to show "Away!" even though the IP address matches one of those listed in the "OR" match test.

If I remove the OR and limit IfMatch to the single IP address, the measure and meter work fine.

Any other ideas?
Cheers!

Chuck
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5543
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: IfMatch IP Address and Reserved Characters

Post by eclectic-tech »

cwfrizzell wrote: June 7th, 2024, 1:27 am Thanks for the response. Unfortunately, it did not work. The meter continues to show "Away!" even though the IP address matches one of those listed in the "OR" match test.

If I remove the OR and limit IfMatch to the single IP address, the measure and meter work fine.

Any other ideas?
Worked for my test, but the only other thought would be to do the comparison in separate IfMatch tests.

Code: Select all

[mIP]
Measure=Plugin
Plugin=SysInfo
SysInfoType=IP_ADDRESS
SysInfoData=Best
UpdateDivider=5
DynamicVariables=1
IfMatch=XXX\.XXX\.X\.XXX
IfMatchAction=[!SetOption IPMeter Text "HOME"]
IfMatch2=YYY\.YYY\.Y\.YYY
IfMatchAction2=[!SetOption IPMeter Text "AWAY!"]
IfMatchMode=1

[IPMeter]
Meter=String
Text=
FontColor=255,255,255
EDIT: I noticed you had 'tab' characters at the end of your IfMatch string... make sure that isn't causing an issue.
User avatar
cwfrizzell
Posts: 80
Joined: August 10th, 2009, 9:03 pm

Re: IfMatch IP Address and Reserved Characters

Post by cwfrizzell »

Found my mistake. Resolved thanks!
Cheers!

Chuck