<?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 to pass value to python script from a Input.conf in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462808#M79877</link>
    <description>&lt;P&gt;@kamlesh_vaghela it worked.thanks&lt;/P&gt;</description>
    <pubDate>Thu, 23 Apr 2020 08:15:08 GMT</pubDate>
    <dc:creator>DataOrg</dc:creator>
    <dc:date>2020-04-23T08:15:08Z</dc:date>
    <item>
      <title>How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462799#M79868</link>
      <description>&lt;P&gt;i need to pass the host value in the URL from external file to the python script. how to pass it through conf file? please help&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    import requests
    headers={
            "accept": "application/json",
            "content-type": "application/json"
        }
    res = requests.get('https://"&amp;lt;passvalue&amp;gt;"/home/method=post/end',headers=headers )

    print(res.text)


inputs.conf
[script://.\bin\gettinfdata.py]
interval = * * * * *
sourcetype = pythondata
disabled = False 
index = test
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Apr 2020 13:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462799#M79868</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-04-01T13:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462800#M79869</link>
      <description>&lt;P&gt;where is the external file located? Does the python script have an access to this file? You have to build all logic in the python script itself, the script stanza in inputs.conf doesn't accept any parameters, only the path to the script.&lt;/P&gt;

&lt;P&gt;Other option is to use the .path file where you can use parameters:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;cmd can also be a path to a file that ends with a ".path" suffix. A file
  with this suffix is a special type of pointer file that points to a command
  to be run. Although the pointer file is bound by the same location
  restrictions mentioned above, the command referenced inside it can reside
  anywhere on the file system. The .path file must contain exactly one line:
  the path to the command to run, optionally followed by command-line
  arguments. The file can contain additional empty lines and lines that begin
  with '#'. The input ignores these lines.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;you can also use a wrapper script that first extract a host value from the file and pass it as parameter to the script&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 13:53:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462800#M79869</guid>
      <dc:creator>PavelP</dc:creator>
      <dc:date>2020-04-01T13:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462801#M79870</link>
      <description>&lt;P&gt;see&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/489612/how-to-use-python-scripts-as-a-scripted-input-for.html"&gt;https://answers.splunk.com/answers/489612/how-to-use-python-scripts-as-a-scripted-input-for.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2020 21:12:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462801#M79870</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-01T21:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462802#M79871</link>
      <description>&lt;P&gt;@PavelP i tried using .path file to pass arguments, still it doesnt work, could you please check whether the stanza.&lt;/P&gt;

&lt;P&gt;$SPLUNK_HOME\etc\apps\apps\bin\sample.py 'host1'&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 07:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462802#M79871</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-04-13T07:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462803#M79872</link>
      <description>&lt;P&gt;@kamlesh_vaghela can you please help me here?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 07:44:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462803#M79872</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-04-13T07:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462804#M79873</link>
      <description>&lt;P&gt;@premranjithj &lt;/P&gt;

&lt;P&gt;When dynamic parameter comes, I aways suggest Modular input over scripted input.  It has its own features. &lt;/P&gt;

&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.3/AdvancedDev/ModInputsIntro"&gt;https://docs.splunk.com/Documentation/Splunk/6.4.3/AdvancedDev/ModInputsIntro&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Input scripted input did you tried passing an argument in the script?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [script://.\bin\gettinfdata.py HostName]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Apr 2020 09:09:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462804#M79873</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-04-13T09:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462805#M79874</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/45389"&gt;@DataOrg&lt;/a&gt; : are you sure the your sample.py script accept arguments? Hier is an example what I have in my .path file and it works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/usr/sbin/tcpdump -pnns0 -i eth0 -tttt port 53
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here is my inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script://./bin/tcpdump.path]
interval = -1
disabled = 0 
sourcetype = port53tttt
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here is my tcpdump.path file ($SPLUNK_HOME/etc/apps/TA_tcpdump/bin/tcpdump.path):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/usr/sbin/tcpdump -pnns0 -i eth0 -tttt port 53
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:00:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462805#M79874</guid>
      <dc:creator>PavelP</dc:creator>
      <dc:date>2020-09-30T05:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462806#M79875</link>
      <description>&lt;P&gt;Hello @premranjithj &lt;/P&gt;

&lt;P&gt;here is an example based on your original script.&lt;/P&gt;

&lt;P&gt;Modify your script to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import requests
import sys

domain = sys.argv[1]

# here you need to add some input validation checks!!! DO NOT SKIP THIS STEP!!

headers={
         "accept": "application/json",
         "content-type": "application/json"
}

res = requests.get('http://' + domain ,headers=headers )

print(res.text)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here is your inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script://.\bin\gettinfdata.path]
interval = * * * * *
sourcetype = pythondata
disabled = False 
index = test
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here is your gettinfdata.path:&lt;BR /&gt;
    .\bin\gettinfdata.path example.com&lt;/P&gt;

&lt;P&gt;But if I understand you right you need &lt;EM&gt;to pass the host value in the URL from external file to the python script.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;So instead I'd just modify your .py script and add a code part &lt;STRONG&gt;to read from an external file&lt;/STRONG&gt;. &lt;/P&gt;

&lt;P&gt;Please describe what is your use case and where is the external file located and what is its content.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 12:50:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462806#M79875</guid>
      <dc:creator>PavelP</dc:creator>
      <dc:date>2020-04-13T12:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462807#M79876</link>
      <description>&lt;P&gt;Hi @PaveIP&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/816567/splunk-python-with-pandas.html"&gt;https://answers.splunk.com/answers/816567/splunk-python-with-pandas.html&lt;/A&gt;&lt;BR /&gt;
Can you resolve this?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 13:02:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462807#M79876</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-13T13:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462808#M79877</link>
      <description>&lt;P&gt;@kamlesh_vaghela it worked.thanks&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 08:15:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462808#M79877</guid>
      <dc:creator>DataOrg</dc:creator>
      <dc:date>2020-04-23T08:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to pass value to python script from a Input.conf</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462809#M79878</link>
      <description>&lt;P&gt;Glad to help you @premranjithj &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 10:07:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-pass-value-to-python-script-from-a-Input-conf/m-p/462809#M79878</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-04-23T10:07:44Z</dc:date>
    </item>
  </channel>
</rss>

