<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Parsing regular expression variable to script?]]></title><description><![CDATA[<p dir="auto">I'm having issues and i'm not sure if its related to the recent update (which has broken a lot of my scripts hence why i'm rewriting a lot of it)</p>
<p dir="auto">I have this as a script with some debugging in it</p>
<pre><code>// Radio mode check
// First parameter = Node to check
// Second parameter = Vendor ID / Object ID (uses regex expression). Acts as a prequalifier before proceeding
// Third parameter = SNMP OID to check the radio mode, script will return this value
if ($1 == null) {println "Please specify node as first parameter"; return -1;}
if ($2 == null) {println "Please specify Vendor/Object OID as second parameter"; return -1;}
if ($3 == null) {println "Please specify SNMP OID as third parameter"; return -1;}

tempvar = FindObject($1);
println $2;
println tempvar-&gt;snmpOID;

// First check for appropriate Vendor ID
if (tempvar-&gt;snmpOID ~= $2) {
 println "match was made";
 println "----";
 println $1;
 println $2;
 println $3;
 println "----";
 transport = CreateSNMPTransport(tempvar); // Open SNMP Session
 if (transport == null) println "Could not open SNMP session" ; return -2; // If can't open session, abort
 // Now check if AP or SM
 mode = SNMPGetValue(transport, $3);
 if (mode == null) println "Failed to retrieve OID $3"; return -3;
 return mode;
};
println "Vendor ID not a match"; return -4;
</code></pre>
<p dir="auto">I'm sending this to the server console</p>
<pre><code>exec RadioMode 27560 "(.1.3.6.1.4.1.17713.21.9).*" .1.3.6.1.4.1.17713.21.3.8.2.1.0
</code></pre>
<p dir="auto">First parameter is a nodes object ID<br />
Second parameter is a regex expression that should match the Object ID / Vendor ID which in this case has .39 appended to it (all radio's in this range have a different number but they all begin with .1.3.6.1.4.1.17713.21.9)<br />
Third parameter is the value to check and it should return 1/2/3 depending on the mode that the radio is in (AP/SM/Spectrum Scan)</p>
<p dir="auto">It's failing at <strong>if (tempvar-&gt;snmpOID ~= $2) {</strong><br />
It seems to accept it as a regular expression but its like its being treated as a literal string or something. If I instead replace the $2 with the exact same regular expression (typed into the script itself, not taken from a variable) it recognises it as a match and proceeds just fine</p>
<p dir="auto">I have other issues in this script such as the SNMPTransport seemingly not being created but we'll cross that bridge later</p>
]]></description><link>https://forum.netxms.org/topic/6245/parsing-regular-expression-variable-to-script</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 11:41:30 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/6245.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Oct 2019 07:03:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Parsing regular expression variable to script? on Fri, 25 Oct 2019 12:46:52 GMT]]></title><description><![CDATA[<p dir="auto">Server console is not analyzing double quotes - enquoted arguments are just passed to the script as string having quotes on both ends, that's why it's not matching.</p>
]]></description><link>https://forum.netxms.org/post/26823</link><guid isPermaLink="true">https://forum.netxms.org/post/26823</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Fri, 25 Oct 2019 12:46:52 GMT</pubDate></item></channel></rss>