<?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: Why is my script exiting with code 1 on enterprise security app when I run a script action? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-script-exiting-with-code-1-on-enterprise-security-app/m-p/340734#M62844</link>
    <description>&lt;P&gt;My bad for not pointing this...&lt;BR /&gt;
1. in my origin script /bin/bash is as expected (without )&lt;BR /&gt;
2. curl command is not 'echo'ed. i forgot to remove it while copy-paste here.&lt;/P&gt;

&lt;P&gt;sorry.&lt;BR /&gt;
anyway, you actually see -o output while splunk runs the script.&lt;/P&gt;

&lt;P&gt;any other ideas what is the BIG diff between splunk and cli?&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2018 22:08:36 GMT</pubDate>
    <dc:creator>OBsecurity</dc:creator>
    <dc:date>2018-02-01T22:08:36Z</dc:date>
    <item>
      <title>Why is my script exiting with code 1 on enterprise security app when I run a script action?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-script-exiting-with-code-1-on-enterprise-security-app/m-p/340732#M62842</link>
      <description>&lt;P&gt;Hello Folks.&lt;BR /&gt;
I've created a script that should initiate 'HIPCHAT' messaging application api's.&lt;BR /&gt;
While running the script (on the es machine) via cli it works fine. After 3 days of workarounds - ES 'run a script' action runs the script and fails with exit code 1 no matter what I've tried.&lt;/P&gt;

&lt;P&gt;This is the command for the api. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/usr/bin/curl -H 'Content-Type: application/json' -X 'POST' -d '{"message_format": "text", "message": "Threat - hipchat - Rule"}' 'https://api.hipchat.com/v2/room/4415200/notification?auth_token=mytoken' 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is the script: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\#!/bin/bash 

ROOM_ID=4415200 
AUTH_TOKEN=mytoken


curl="'""Content-Type: application/json""'" 
echo curl=$curl &amp;gt;&amp;gt; "/opt/splunk/bin/scripts/splunk-hiptest.out" 

post="'""POST""'" 
echo post=$post &amp;gt;&amp;gt; "/opt/splunk/bin/scripts/splunk-hiptest.out" 


MESSAGE="'""{\"message_format\": \"text\", \"message\": \"$4\"}""'" 
echo message=$MESSAGE &amp;gt;&amp;gt; "/opt/splunk/bin/scripts/splunk-hiptest.out" 

url="'""https://api.hipchat.com/v2/room/4415200/notification?auth_token=mytoken""'" 
echo url=$url &amp;gt;&amp;gt; "/opt/splunk/bin/scripts/splunk-hiptest.out" 



echo curl -H $curl \ 
-X $post \ 
-d $MESSAGE \ 
$url &amp;gt;&amp;gt; "/opt/splunk/bin/scripts/splunk-hiptest.out" 


echo curl_exit_code = $? &amp;gt;&amp;gt; "/opt/splunk/bin/scripts/splunk-hiptest.out" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Workarounds&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;tried to run a script with a single command row.&lt;/LI&gt;
&lt;LI&gt;tried to build the command with\without args.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;please help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2018 10:35:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-script-exiting-with-code-1-on-enterprise-security-app/m-p/340732#M62842</guid>
      <dc:creator>OBsecurity</dc:creator>
      <dc:date>2018-01-31T10:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my script exiting with code 1 on enterprise security app when I run a script action?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-script-exiting-with-code-1-on-enterprise-security-app/m-p/340733#M62843</link>
      <description>&lt;P&gt;You can change to&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; \#!/bin/bash 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; echo curl -H $curl \ 
 -X $post \ 
 -d $MESSAGE \ 
 $url &amp;gt;&amp;gt; "/opt/splunk/bin/scripts/splunk-hiptest.out" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should be&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -H $curl \
 -X $post \ 
 -d $MESSAGE \ 
-o "/opt/splunk/bin/scripts/splunk-hiptest.out" \
 $url
curl_exit_code=$?
echo $curl_exit_code &amp;gt;&amp;gt; /opt/splunk/bin/scripts/splunk-hiptest.out
exit $curl_exit_code
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Feb 2018 09:51:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-script-exiting-with-code-1-on-enterprise-security-app/m-p/340733#M62843</guid>
      <dc:creator>jeanyvesnolen</dc:creator>
      <dc:date>2018-02-01T09:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my script exiting with code 1 on enterprise security app when I run a script action?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-script-exiting-with-code-1-on-enterprise-security-app/m-p/340734#M62844</link>
      <description>&lt;P&gt;My bad for not pointing this...&lt;BR /&gt;
1. in my origin script /bin/bash is as expected (without )&lt;BR /&gt;
2. curl command is not 'echo'ed. i forgot to remove it while copy-paste here.&lt;/P&gt;

&lt;P&gt;sorry.&lt;BR /&gt;
anyway, you actually see -o output while splunk runs the script.&lt;/P&gt;

&lt;P&gt;any other ideas what is the BIG diff between splunk and cli?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2018 22:08:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-script-exiting-with-code-1-on-enterprise-security-app/m-p/340734#M62844</guid>
      <dc:creator>OBsecurity</dc:creator>
      <dc:date>2018-02-01T22:08:36Z</dc:date>
    </item>
  </channel>
</rss>

