<?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: script input not working when parameter is passed as a variable and not the static value in inputs.conf in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470414#M80885</link>
    <description>&lt;P&gt;where is "PRA.conf" located.&lt;BR /&gt;
Scripts do not execute with ./app/bin as the working directory.&lt;BR /&gt;
Its probable therefore that PRA.conf is not being found, and thus not expanded.&lt;/P&gt;

&lt;P&gt;Can you try specifying the path fully in the script?&lt;BR /&gt;
&lt;CODE&gt;url=$(cat /opt/splunkforwarder/etc/apps/search/bin/scripts/PRA.conf | grep $1 | awk -F "=" '{print $2}')&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Feb 2020 13:59:09 GMT</pubDate>
    <dc:creator>nickhills</dc:creator>
    <dc:date>2020-02-11T13:59:09Z</dc:date>
    <item>
      <title>script input not working when parameter is passed as a variable and not the static value in inputs.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470413#M80884</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I am using a script to fetch http response as splunk raw event. For this I am passing parameter as a variable, whose value is in another conf file. &lt;BR /&gt;
The inputs.conf is as below:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;[script:///opt/splunkforwarder/etc/apps/search/bin/scripts/urlhealthcheck.sh HEALTHCHECK_URL ]&lt;BR /&gt;
sourcetype = healthcheck&lt;BR /&gt;
disabled = false&lt;BR /&gt;
interval = 300&lt;BR /&gt;
index = main&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The configuration file where the parameter HEALTHCHECK_URL is stored;example.conf&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;HEALTHCHECK_URL=&lt;A href="https://healthcheckurl.domain.com"&gt;https://healthcheckurl.domain.com&lt;/A&gt;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The shell script  urlhealthcheck.sh;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;#!/bin/sh&lt;BR /&gt;
url=$(cat PRA.conf | grep $1 | awk -F "=" '{print $2}')&lt;BR /&gt;
responsecode=$(wget -S --spider --no-check-certificate $url 2&amp;gt;&amp;amp;1 | grep "HTTP/" | awk '{print $2}')&lt;BR /&gt;
response=$(wget -q  --no-check-certificate -O - $url 2&amp;gt;&amp;amp;1 )&lt;BR /&gt;
echo "URL=$url, ResponseCode=$responsecode, Response=$response"&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;This shell script is running perfectly when run from the terminal as&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;sh /opt/splunkforwarder/etc/apps/search/bin/scripts/urlhealthcheck.sh HEALTHCHECK_URL&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Or run as &lt;/P&gt;

&lt;P&gt;./opt/splunkforwarder/etc/apps/search/bin/scripts/urlhealthcheck.sh HEALTHCHECK_URL &lt;/P&gt;

&lt;P&gt;giving output as ;&lt;BR /&gt;
&lt;EM&gt;[&lt;BR /&gt;
    {&lt;BR /&gt;
        "code": 200,&lt;BR /&gt;
        "response": "Health Check: Succeeded"&lt;BR /&gt;
    }&lt;BR /&gt;
]&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;But in inputs.conf this giving the response as ;&lt;BR /&gt;
&lt;EM&gt;wget: missing URL&lt;BR /&gt;
Usage: wget [OPTION]... [URL]...&lt;BR /&gt;
Try `wget --help' for more options.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;If I change the parameter from  HEALTHCHECK_URL to &lt;A href="https://healthcheckurl.domain.com"&gt;https://healthcheckurl.domain.com&lt;/A&gt; as the http response is coming out correct without an error.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;[script:///opt/splunkforwarder/etc/apps/search/bin/scripts/urlhealthcheck.sh &lt;A href="https://healthcheckurl.domain.com"&gt;https://healthcheckurl.domain.com&lt;/A&gt; ]&lt;BR /&gt;
sourcetype = healthcheck&lt;BR /&gt;
disabled = false&lt;BR /&gt;
interval = 300&lt;BR /&gt;
index = main&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;What is the reason that I am not able to pass the parameter as a variable through the inputs.conf, though the script is working fine?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 13:17:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470413#M80884</guid>
      <dc:creator>sara91</dc:creator>
      <dc:date>2020-02-11T13:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: script input not working when parameter is passed as a variable and not the static value in inputs.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470414#M80885</link>
      <description>&lt;P&gt;where is "PRA.conf" located.&lt;BR /&gt;
Scripts do not execute with ./app/bin as the working directory.&lt;BR /&gt;
Its probable therefore that PRA.conf is not being found, and thus not expanded.&lt;/P&gt;

&lt;P&gt;Can you try specifying the path fully in the script?&lt;BR /&gt;
&lt;CODE&gt;url=$(cat /opt/splunkforwarder/etc/apps/search/bin/scripts/PRA.conf | grep $1 | awk -F "=" '{print $2}')&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 13:59:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470414#M80885</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-02-11T13:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: script input not working when parameter is passed as a variable and not the static value in inputs.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470415#M80886</link>
      <description>&lt;P&gt;Thankyou. It is working&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 19:13:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470415#M80886</guid>
      <dc:creator>sara91</dc:creator>
      <dc:date>2020-02-11T19:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: script input not working when parameter is passed as a variable and not the static value in inputs.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470416#M80887</link>
      <description>&lt;P&gt;Great news!, Please accept my answer so others can see what the solution was in the furture!&lt;/P&gt;</description>
      <pubDate>Tue, 11 Feb 2020 19:31:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/script-input-not-working-when-parameter-is-passed-as-a-variable/m-p/470416#M80887</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-02-11T19:31:38Z</dc:date>
    </item>
  </channel>
</rss>

