<?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[Script error at automatic apply rule - Bad arithmetic conversion]]></title><description><![CDATA[<p dir="auto">Hello @all,</p>
<p dir="auto">i use the following script as automatic apply rule in a template (NetXMS V2.1.2):</p>
<pre><code>if ( (! $node-&gt;isAgent) &amp;&amp; (! $node-&gt;platformName ~= "windows.*") ) return false;

table = AgentReadTable($node, "System.Services");
if ( table == null ) return false;

colName = table-&gt;getColumnIndex("NAME");
for (currentRow = 0; currentRow &lt; table-&gt;rowCount; currentRow++)
{
	if ( table-&gt;get(currentRow, colName) == "DNS" ) return true;
}

return false;
</code></pre>
<p dir="auto">Everytime the script is processed automaticly at a node the following event is thrown:</p>
<p dir="auto">   Script (Template::Server Service DNS::730) execution error: Error 4 in line 1: Bad arithmetic conversion</p>
<p dir="auto">but the script is proccessed correctly.</p>
<p dir="auto">If i create this script in script library and test the script with "Execute Server Script" with a node, there is no error...</p>
<p dir="auto">Where is my fault?  Thanks for helping me...</p>
<p dir="auto">Greets<br />
Marco</p>
]]></description><link>https://forum.netxms.org/topic/5278/script-error-at-automatic-apply-rule-bad-arithmetic-conversion</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 13:59:13 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/5278.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 16 Oct 2017 09:26:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Script error at automatic apply rule - Bad arithmetic conversion on Thu, 26 Oct 2017 15:40:39 GMT]]></title><description><![CDATA[<p dir="auto">Hello Victor,</p>
<p dir="auto">thanks for the clarification.</p>
<p dir="auto">Greetings<br />
Marco</p>
]]></description><link>https://forum.netxms.org/post/23262</link><guid isPermaLink="true">https://forum.netxms.org/post/23262</guid><dc:creator><![CDATA[Spheron]]></dc:creator><pubDate>Thu, 26 Oct 2017 15:40:39 GMT</pubDate></item><item><title><![CDATA[Reply to Script error at automatic apply rule - Bad arithmetic conversion on Wed, 18 Oct 2017 12:55:49 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">"logical not" operation (!) has higher priority than "match" operation (~=). So your script actually does logical not on text string ($node-&gt;platformName) which causes runtime error. It only happens on nodes without agent. You should get match operation in brackets:</p>
<p dir="auto">(!($node-&gt;platformName ~= "windows.*"))</p>
<p dir="auto">Also, I suspect you have logical error here. You probably want to return false if there is no agent OR platform is not Windows - but current condition uses AND which is pointless - if node has no agent platform name will be empty anyway and won't match anyway.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/23224</link><guid isPermaLink="true">https://forum.netxms.org/post/23224</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Wed, 18 Oct 2017 12:55:49 GMT</pubDate></item></channel></rss>