<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I use an if or eval statement to run a custom search command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369240#M108779</link>
    <description>&lt;P&gt;Try something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval valueToTest=if( your test here ,1,2)
  | appendpipe [ | where valueToTest==1 | do customCommand1 | eval rectype="1"]
  | appendpipe [ | where valueToTest==2 | do customCommand2 | eval rectype="2"]
  | where isnotnull(rectype)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Nov 2017 21:13:03 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-11-14T21:13:03Z</dc:date>
    <item>
      <title>How can I use an if or eval statement to run a custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369238#M108777</link>
      <description>&lt;P&gt;Hello Splunkers - &lt;/P&gt;

&lt;P&gt;Can't figure out for the life of me how to use eval or if statement to call a custom search command if an eval returns true.  What I am doing is running an eval and testing some values, I would like to run custom command 1 if the statement tests to 1 and another custom command if it tests to 0.  Any thoughts?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval valueToTest=if(isnotnull(statementHere),0,1)
| if (1 do customCommand1)
| if (0 do customCommand2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Nov 2017 00:47:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369238#M108777</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2017-11-14T00:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use an if or eval statement to run a custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369239#M108778</link>
      <description>&lt;P&gt;As far as I know this is still not possible out of the box, but you could put the logic into your custom command instead.&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 00:50:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369239#M108778</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-11-14T00:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use an if or eval statement to run a custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369240#M108779</link>
      <description>&lt;P&gt;Try something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | eval valueToTest=if( your test here ,1,2)
  | appendpipe [ | where valueToTest==1 | do customCommand1 | eval rectype="1"]
  | appendpipe [ | where valueToTest==2 | do customCommand2 | eval rectype="2"]
  | where isnotnull(rectype)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Nov 2017 21:13:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369240#M108779</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-11-14T21:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use an if or eval statement to run a custom search command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369241#M108780</link>
      <description>&lt;P&gt;This partially works, I think.  rec values populate but the fields and values that should be returned by the script never actually come back when run inside the appendpipe.  Is there a way for that?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 17:08:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-an-if-or-eval-statement-to-run-a-custom-search/m-p/369241#M108780</guid>
      <dc:creator>splunker1981</dc:creator>
      <dc:date>2017-11-16T17:08:18Z</dc:date>
    </item>
  </channel>
</rss>

