<?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 External Commands calling perl script fails in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/External-Commands-calling-perl-script-fails/m-p/72994#M181019</link>
    <description>&lt;P&gt;I have been able to have my external commands use subprocess to call commands because not all modules exist in the splunk environment and that has worked fine. I now need to call a perl script because the data I am retrieving is only accessible through a perl API. I need to call a perl script from within and external python command and I can't get it to work. It works great for shell scripts and python scripts but not for perl. The script works outside of splunk but not from within splunk. I must be not getting something from the environment within splunk but don't know what it is.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;
This works fine outside of splunk but does note even execute within splunk. (I didn't include the splunk imports and processing, just the function that it is calling.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;
    #!/usr/bin/python&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import subprocess
import os

def getemp(host):
  cmd = ("/usr/bin/perl","/opt/splunk/etc/apps/KtN/bin/mrilookup.pl",host)
  pseudohandle = subprocess.Popen(cmd,stdin=subprocess.PIPE,            stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False)
  pseudohandle.stdin.write(host)
  stdout, stderr = pseudohandle.communicate()
  pseudohandle.stdin.close()
  return  stdout.rstrip()

print getemp("bugs")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 24 Mar 2013 14:41:30 GMT</pubDate>
    <dc:creator>rdownie</dc:creator>
    <dc:date>2013-03-24T14:41:30Z</dc:date>
    <item>
      <title>External Commands calling perl script fails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/External-Commands-calling-perl-script-fails/m-p/72994#M181019</link>
      <description>&lt;P&gt;I have been able to have my external commands use subprocess to call commands because not all modules exist in the splunk environment and that has worked fine. I now need to call a perl script because the data I am retrieving is only accessible through a perl API. I need to call a perl script from within and external python command and I can't get it to work. It works great for shell scripts and python scripts but not for perl. The script works outside of splunk but not from within splunk. I must be not getting something from the environment within splunk but don't know what it is.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;
This works fine outside of splunk but does note even execute within splunk. (I didn't include the splunk imports and processing, just the function that it is calling.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;
    #!/usr/bin/python&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import subprocess
import os

def getemp(host):
  cmd = ("/usr/bin/perl","/opt/splunk/etc/apps/KtN/bin/mrilookup.pl",host)
  pseudohandle = subprocess.Popen(cmd,stdin=subprocess.PIPE,            stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=False)
  pseudohandle.stdin.write(host)
  stdout, stderr = pseudohandle.communicate()
  pseudohandle.stdin.close()
  return  stdout.rstrip()

print getemp("bugs")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 24 Mar 2013 14:41:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/External-Commands-calling-perl-script-fails/m-p/72994#M181019</guid>
      <dc:creator>rdownie</dc:creator>
      <dc:date>2013-03-24T14:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: External Commands calling perl script fails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/External-Commands-calling-perl-script-fails/m-p/72995#M181020</link>
      <description>&lt;P&gt;I found if I take out the added per libs it works. How do I get the perl libs added? I tried both use lib xxx and push @INC xxx within the perl script and they appear to be ignored. If I run the script as the splunk user either way they work. It is only when the external command using subprocess call the script that it fails.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2013 15:11:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/External-Commands-calling-perl-script-fails/m-p/72995#M181020</guid>
      <dc:creator>rdownie</dc:creator>
      <dc:date>2013-03-24T15:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: External Commands calling perl script fails</title>
      <link>https://community.splunk.com/t5/Splunk-Search/External-Commands-calling-perl-script-fails/m-p/72996#M181021</link>
      <description>&lt;P&gt;Finally figured it out. I added the PER5LIB path to the subproccess command via env={"PERL5LIB":"/path_to_lib"}&lt;BR /&gt;
It works!!!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:35:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/External-Commands-calling-perl-script-fails/m-p/72996#M181021</guid>
      <dc:creator>rdownie</dc:creator>
      <dc:date>2020-09-28T13:35:34Z</dc:date>
    </item>
  </channel>
</rss>

