<?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 do I run a script from a button on a dashboard? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436563#M28785</link>
    <description>&lt;P&gt;No worries mate. If this resolves your issue please accept it as answer. Have a nice day.&lt;/P&gt;

&lt;P&gt;Sid&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jan 2019 07:53:40 GMT</pubDate>
    <dc:creator>sdchakraborty</dc:creator>
    <dc:date>2019-01-28T07:53:40Z</dc:date>
    <item>
      <title>How do I run a script from a button on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436557#M28779</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I want to run the script from a button on a dashboard.&lt;/P&gt;

&lt;P&gt;Running the RUN_TEST.sh from as an alert is working (Alert_test).&lt;/P&gt;

&lt;P&gt;Do i call the alert that will then call the .sh or can i call the .sh directly?&lt;/P&gt;

&lt;P&gt;Example of button. But i have no idea how to run the RUN_TEST.sh  (splunk/bin/scripts/RUN_TEST.sh)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;html&amp;gt;
        &amp;lt;button class="btn" data-token-json="{&amp;amp;quot;execute_save_test&amp;amp;quot;:&amp;amp;quot;     RUN_TEST.sh     }"&amp;gt;RUN TEST SCRIPT&amp;lt;/button&amp;gt;
      &amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance&lt;BR /&gt;
Rob&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:23:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436557#M28779</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2020-09-29T22:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run a script from a button on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436558#M28780</link>
      <description>&lt;P&gt;@robertlynch2020 how about you set a token on HTML button click using Splunk JS and Simple XML JS extension (may be the token value can be shell script name itself). Then run the SPL with &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Script"&gt;script&lt;/A&gt; command, which will execute only when the token is set (i.e. on HTML button click).  &lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 17:54:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436558#M28780</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-12-13T17:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run a script from a button on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436559#M28781</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I will try to explain what I have done. Probably it will be helpful and you can customize according to your need. &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;I am in windows so I  try solve this issue using batch file. I think the same concept can be applied to .sh file as well.&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I saved my below batch file in a place where I have execute permission. In this case I saved in my desktop with name sid.bat&lt;/P&gt;

&lt;P&gt;@echo off&lt;BR /&gt;
color 0a&lt;BR /&gt;
mode 1000&lt;/P&gt;

&lt;P&gt;echo %random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random%%random% &amp;gt; C:\Users\s.d.chakraborty\Desktop\test.txt&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Then I created a custom command like below with name test.py and saved in my apps bin folder as usual.&lt;/P&gt;

&lt;P&gt;import subprocess&lt;BR /&gt;
subprocess.call([r'C:\Users\s.d.chakraborty\Desktop\sid.bat'])&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;I configured commands.conf like below,&lt;/P&gt;

&lt;P&gt;[testcmd]&lt;BR /&gt;
filename = test.py&lt;BR /&gt;
enableheader = true &lt;BR /&gt;
outputheader = true&lt;BR /&gt;
requires_srinfo = true&lt;BR /&gt;
supports_getinfo = true &lt;BR /&gt;
supports_multivalues = true &lt;BR /&gt;
supports_rawargs = true &lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;The I created a sample dashboard with checkbox to run the script. Here you can replace with your HTML button logic as well for token setting.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;&lt;IMG src="http://C:Userss.d.chakrabortyDesktopdashboard.PNG" alt="alt text" /&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;demo&amp;lt;/label&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;| testcmd | eval ignore = $form.tokQuery$&amp;lt;/query&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input type="checkbox" token="dummy" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
      &amp;lt;choice value="run"&amp;gt;Run&amp;lt;/choice&amp;gt;
      &amp;lt;delimiter&amp;gt; &amp;lt;/delimiter&amp;gt;
        &amp;lt;change&amp;gt;
           &amp;lt;set token="form.tokQuery"&amp;gt;nothing&amp;lt;/set&amp;gt;
         &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if everything goes file it should create a file called test.txt.&lt;/P&gt;

&lt;P&gt;Please let me know hot it goes for you. I tested it once and it works for me.&lt;/P&gt;

&lt;P&gt;Sid&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:28:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436559#M28781</guid>
      <dc:creator>sdchakraborty</dc:creator>
      <dc:date>2020-09-29T22:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run a script from a button on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436560#M28782</link>
      <description>&lt;P&gt;@robertlynch2020  Is your problem resolved?  If so, please accept the answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 21:09:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436560#M28782</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-01-12T21:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run a script from a button on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436561#M28783</link>
      <description>&lt;P&gt;Hi @sdchakraborty ,&lt;/P&gt;

&lt;P&gt;Tried this and it works for me. However, there were multiple results for my script. The script inside the *.py will send an email to specific recipients, but there were 3 emails being sent upon single execution. Even if I only tried this on adhoc search command, the error is still the same. See below.&lt;/P&gt;

&lt;P&gt;01-28-2019 15:04:31.435 ERROR script - Getinfo probe failed for external search command ''&lt;BR /&gt;
01-28-2019 15:04:31.435 ERROR SearchPhaseGenerator - Fallback to two phase search failed:Error in 'script': Getinfo probe failed for external search command ''&lt;BR /&gt;
01-28-2019 15:04:31.436 ERROR SearchOrchestrator - Error in 'script': Getinfo probe failed for external search command ''&lt;/P&gt;

&lt;P&gt;This is my first time to use .py. Am I missing some config needed for python script? Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 07:14:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436561#M28783</guid>
      <dc:creator>crladores</dc:creator>
      <dc:date>2019-01-28T07:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run a script from a button on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436562#M28784</link>
      <description>&lt;P&gt;Hi @sdchakraborty,&lt;/P&gt;

&lt;P&gt;I tried to disable &lt;STRONG&gt;supports_getinfo&lt;/STRONG&gt; in commands.conf and it works perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
Thank you for your detailed steps above. God bless you!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 07:22:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436562#M28784</guid>
      <dc:creator>crladores</dc:creator>
      <dc:date>2019-01-28T07:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I run a script from a button on a dashboard?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436563#M28785</link>
      <description>&lt;P&gt;No worries mate. If this resolves your issue please accept it as answer. Have a nice day.&lt;/P&gt;

&lt;P&gt;Sid&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 07:53:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-I-run-a-script-from-a-button-on-a-dashboard/m-p/436563#M28785</guid>
      <dc:creator>sdchakraborty</dc:creator>
      <dc:date>2019-01-28T07:53:40Z</dc:date>
    </item>
  </channel>
</rss>

