<?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 Why is my bash scripted input failing on Ubuntu while it's OK on other distros? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402920#M71623</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have an issue with a scripted input.&lt;/P&gt;

&lt;P&gt;I have 2 Linux on Amazon Web Services (AWS) :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;1 based one AWS Linux AMI&lt;/LI&gt;
&lt;LI&gt;1 based on Ubuntu&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;On AWS Linux Amazon Machine Image (AMI) :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;script is OK when launched manually&lt;/LI&gt;
&lt;LI&gt;script is OK when launched by Splunk via scripted input&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;On Ubuntu :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;script is OK when launched manually&lt;/LI&gt;
&lt;LI&gt;script KO when launched by Splunk via scripted input&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I would get errors like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in sitecustomize; set PYTHONVERBOSE for traceback
AttributeError: module 'sys' has no attribute 'setdefaultencoding'
prepare_body() takes 3 positional arguments but 4 were given
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I do not know why it even mention Python since it is a bash script.&lt;/P&gt;

&lt;P&gt;I try each line of the script one by one but, via Splunk it fails at things such as :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\#!/usr/bin/env bash

set -o nounset

START_TIME="${SECONDS}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;---&amp;gt; Fails saying SECONDS is not declared and since using 'set -o nounset'.&lt;/P&gt;

&lt;P&gt;But SECONDS is an internal variable, and since : &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I do not meet that issue in other ways script is launched (on Linux AMI &amp;amp; manually on Ubuntu)&lt;/LI&gt;
&lt;LI&gt;I get other weird errors for other small instructions anyhow&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Hence, sorry for not posting more clear error examples, but since the script seems all OK in other contexts as mentioned, I feeI feel like I am missing something in the way the script is being launched by Splunk.&lt;/P&gt;

&lt;P&gt;Is there anything specific I should take into account running a bash script from Splunk on Ubuntu ?&lt;/P&gt;

&lt;P&gt;Is there a way to launch such a script using a Splunk command like it can be done for Python using "splunk cmd python script.py" ?&lt;/P&gt;

&lt;P&gt;Thanks in advance for any hints!&lt;/P&gt;</description>
    <pubDate>Sun, 25 Nov 2018 23:20:43 GMT</pubDate>
    <dc:creator>D2SI</dc:creator>
    <dc:date>2018-11-25T23:20:43Z</dc:date>
    <item>
      <title>Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402920#M71623</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have an issue with a scripted input.&lt;/P&gt;

&lt;P&gt;I have 2 Linux on Amazon Web Services (AWS) :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;1 based one AWS Linux AMI&lt;/LI&gt;
&lt;LI&gt;1 based on Ubuntu&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;On AWS Linux Amazon Machine Image (AMI) :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;script is OK when launched manually&lt;/LI&gt;
&lt;LI&gt;script is OK when launched by Splunk via scripted input&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;On Ubuntu :&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;script is OK when launched manually&lt;/LI&gt;
&lt;LI&gt;script KO when launched by Splunk via scripted input&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I would get errors like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in sitecustomize; set PYTHONVERBOSE for traceback
AttributeError: module 'sys' has no attribute 'setdefaultencoding'
prepare_body() takes 3 positional arguments but 4 were given
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I do not know why it even mention Python since it is a bash script.&lt;/P&gt;

&lt;P&gt;I try each line of the script one by one but, via Splunk it fails at things such as :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;\#!/usr/bin/env bash

set -o nounset

START_TIME="${SECONDS}"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;---&amp;gt; Fails saying SECONDS is not declared and since using 'set -o nounset'.&lt;/P&gt;

&lt;P&gt;But SECONDS is an internal variable, and since : &lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;I do not meet that issue in other ways script is launched (on Linux AMI &amp;amp; manually on Ubuntu)&lt;/LI&gt;
&lt;LI&gt;I get other weird errors for other small instructions anyhow&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Hence, sorry for not posting more clear error examples, but since the script seems all OK in other contexts as mentioned, I feeI feel like I am missing something in the way the script is being launched by Splunk.&lt;/P&gt;

&lt;P&gt;Is there anything specific I should take into account running a bash script from Splunk on Ubuntu ?&lt;/P&gt;

&lt;P&gt;Is there a way to launch such a script using a Splunk command like it can be done for Python using "splunk cmd python script.py" ?&lt;/P&gt;

&lt;P&gt;Thanks in advance for any hints!&lt;/P&gt;</description>
      <pubDate>Sun, 25 Nov 2018 23:20:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402920#M71623</guid>
      <dc:creator>D2SI</dc:creator>
      <dc:date>2018-11-25T23:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402921#M71624</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Is there a way to launch such script&lt;BR /&gt;
using Splunk command like it can be&lt;BR /&gt;
done for Python using "splunk cmd&lt;BR /&gt;
python script.py" ?&lt;BR /&gt;
splunk cmd script.sh&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 02:01:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402921#M71624</guid>
      <dc:creator>dauren_akilbeko</dc:creator>
      <dc:date>2018-11-26T02:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402922#M71625</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;'splunk cmd script.sh' seems to be working only with the scripted copied to $SPLUNK_HOME/bin, but it works!&lt;/P&gt;

&lt;P&gt;And it generates the same errors I see when launched from the scripted input.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 08:37:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402922#M71625</guid>
      <dc:creator>D2SI</dc:creator>
      <dc:date>2018-11-26T08:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402923#M71626</link>
      <description>&lt;P&gt;Did you check permissions on th script file? &lt;BR /&gt;
Also can you run some other arbitrary script (Echo something), to see if it also fails. &lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 11:34:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402923#M71626</guid>
      <dc:creator>dauren_akilbeko</dc:creator>
      <dc:date>2018-11-26T11:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402924#M71627</link>
      <description>&lt;P&gt;Try adding this to the very top of your script:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;unset LD_LIBRARY_PATH
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If that doesn't do it, try adding this ALSO (keep the above line, too):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;unset PYTHONPATH
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 19:54:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402924#M71627</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-11-26T19:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402925#M71628</link>
      <description>&lt;P&gt;Thanks a lot ! With both, it works on Ubuntu and still works on AWS Linux AMI so it's perfect.&lt;/P&gt;

&lt;P&gt;I tried to run echo $LD_LIBRARY_PATH &amp;amp; $PYTHONPATH, it returned an empty line on both distros.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:08:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402925#M71628</guid>
      <dc:creator>D2SI</dc:creator>
      <dc:date>2020-09-29T22:08:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402926#M71629</link>
      <description>&lt;P&gt;Yes I had double checked on permissions.&lt;/P&gt;

&lt;P&gt;Yes "echo something" would work on Ubuntu, but errors would raise as soon as I introduce small instructions.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 05:56:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402926#M71629</guid>
      <dc:creator>D2SI</dc:creator>
      <dc:date>2018-11-27T05:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my bash scripted input failing on Ubuntu while it's OK on other distros?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402927#M71630</link>
      <description>&lt;P&gt;This drove me crazy until I figured it out.  I forget how long it took...&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 14:58:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-bash-scripted-input-failing-on-Ubuntu-while-it-s-OK-on/m-p/402927#M71630</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-12-07T14:58:10Z</dc:date>
    </item>
  </channel>
</rss>

