<?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: External search command 'mypythonfile' returned error code 1 after Splunk upgrade in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/External-search-command-mypythonfile-returned-error-code-1-after/m-p/142180#M1971</link>
    <description>&lt;P&gt;Hello Harshal,&lt;/P&gt;

&lt;P&gt;It seems the indentation is not correct in the python. To get this correct use below URL to check for Indent related errors. Package related errors are fine. &lt;BR /&gt;
Once you resolve indent related errors, then you can use the file for custom commands. &lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.tutorialspoint.com/execute_python_online.php"&gt;https://www.tutorialspoint.com/execute_python_online.php&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Oct 2016 02:25:23 GMT</pubDate>
    <dc:creator>praveenkpatidar</dc:creator>
    <dc:date>2016-10-06T02:25:23Z</dc:date>
    <item>
      <title>External search command 'mypythonfile' returned error code 1 after Splunk upgrade</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/External-search-command-mypythonfile-returned-error-code-1-after/m-p/142179#M1970</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
 I am trying to run a python file in search command.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;|script python mypythonfile&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I was able to run it the Splunkversion 6.0 before. But when I shifed to 6.1, I am getting the following error while running the command:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;External search command 'mypythonfile' returned error code 1.&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I made the changes in commands.conf too.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;[mypythonfile]&lt;BR /&gt;
filename= mypythonfile.py&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Following is my mypythonfile.py file:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;CODE&gt;from pprint import pprint&lt;BR /&gt;
import socket&lt;BR /&gt;
import sys&lt;BR /&gt;
import os&lt;BR /&gt;
import time&lt;BR /&gt;
import csv&lt;BR /&gt;
import glob&lt;BR /&gt;
import unicodedata&lt;BR /&gt;
import Constants&lt;BR /&gt;
import shutil&lt;BR /&gt;
import splunklib.client as client&lt;BR /&gt;
import splunklib.results as results&lt;BR /&gt;
from xml.dom import minidom&lt;BR /&gt;
from utils import error, parse&lt;BR /&gt;
from time import sleep&lt;BR /&gt;
from array import array&lt;BR /&gt;
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))&lt;BR /&gt;
import SplunkMethods&lt;BR /&gt;
import ParsingAndFilteredCSV&lt;BR /&gt;
import Utilities&lt;BR /&gt;
import BSC&lt;BR /&gt;
import Cell&lt;BR /&gt;
import Network&lt;BR /&gt;
import WeakPerforming&lt;BR /&gt;
import threading&lt;BR /&gt;
from splunklib.modularinput import *&lt;BR /&gt;
from sys import exit&lt;BR /&gt;
try:&lt;BR /&gt;
   import xml.etree.cElementTree as ET&lt;BR /&gt;
except ImportError:&lt;BR /&gt;
   import xml.etree.ElementTree as ET&lt;BR /&gt;
def main(): ####MY CODE######&lt;BR /&gt;
    try:                   &lt;BR /&gt;
    except:&lt;BR /&gt;
       import traceback&lt;BR /&gt;
       stack =  traceback.format_exc()&lt;BR /&gt;
       results = splunk.Intersplunk.generateErrorResults("Error : Traceback: " + str(stack))&lt;BR /&gt;
if __name__ == "__main__":&lt;BR /&gt;
    main()&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Kindly Help...!!!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jul 2014 07:26:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/External-search-command-mypythonfile-returned-error-code-1-after/m-p/142179#M1970</guid>
      <dc:creator>harshal_chakran</dc:creator>
      <dc:date>2014-07-15T07:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: External search command 'mypythonfile' returned error code 1 after Splunk upgrade</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/External-search-command-mypythonfile-returned-error-code-1-after/m-p/142180#M1971</link>
      <description>&lt;P&gt;Hello Harshal,&lt;/P&gt;

&lt;P&gt;It seems the indentation is not correct in the python. To get this correct use below URL to check for Indent related errors. Package related errors are fine. &lt;BR /&gt;
Once you resolve indent related errors, then you can use the file for custom commands. &lt;/P&gt;

&lt;P&gt;&lt;A href="https://www.tutorialspoint.com/execute_python_online.php"&gt;https://www.tutorialspoint.com/execute_python_online.php&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 02:25:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/External-search-command-mypythonfile-returned-error-code-1-after/m-p/142180#M1971</guid>
      <dc:creator>praveenkpatidar</dc:creator>
      <dc:date>2016-10-06T02:25:23Z</dc:date>
    </item>
  </channel>
</rss>

