<?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 Doing my first scripted lookup, trying a basic hello world ... where do I start? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Doing-my-first-scripted-lookup-trying-a-basic-hello-world-where/m-p/460239#M8375</link>
    <description>&lt;P&gt;All,&lt;/P&gt;
&lt;P&gt;Trying to make a basic scripted python lookup. The examples and tutorials were just way over my head. So trying to do something simpler. I coped the example file and tried to simplify the problem a little. What I am aiming to do here is pass a field called 'mystring' and get back a field called 'myoutput'.&lt;/P&gt;
&lt;P&gt;I am passing hello as the field value for mystring and expecting world as the value in the new field myoutput.&lt;/P&gt;
&lt;P&gt;When I execute this I get the following&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;index=*
| head 1
| eval mystring = "hello"
| lookup mylookup mystring
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get" Script execution failed for external search command '/opt/splunk/etc/apps/TA-myapp/bin/mylookup.py'."&lt;/P&gt;
&lt;P&gt;here is my python.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;#!/usr/bin/env python

import csv
import sys


def main():

    if len(sys.argv) != 3:
        print("Usage: python mylookup.py [mystring] [myoutput]")
        sys.exit(1)

    # always passing hello as a eval mystring = "hello"
    mystring = sys.argv[1]
    myoutput = sys.argv[2]

    infile = sys.stdin
    outfile = sys.stdout

    r = csv.DictReader(infile)
    header = r.fieldnames

    w = csv.DictWriter(outfile, fieldnames=r.fieldnames)
    w.writeheader()

    for result in r:
            result[mystring] = "hello"
            result[myoutput] = "world"
            w.writerow(result)

main()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 07 Jun 2020 18:22:37 GMT</pubDate>
    <dc:creator>daniel333</dc:creator>
    <dc:date>2020-06-07T18:22:37Z</dc:date>
    <item>
      <title>Doing my first scripted lookup, trying a basic hello world ... where do I start?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Doing-my-first-scripted-lookup-trying-a-basic-hello-world-where/m-p/460239#M8375</link>
      <description>&lt;P&gt;All,&lt;/P&gt;
&lt;P&gt;Trying to make a basic scripted python lookup. The examples and tutorials were just way over my head. So trying to do something simpler. I coped the example file and tried to simplify the problem a little. What I am aiming to do here is pass a field called 'mystring' and get back a field called 'myoutput'.&lt;/P&gt;
&lt;P&gt;I am passing hello as the field value for mystring and expecting world as the value in the new field myoutput.&lt;/P&gt;
&lt;P&gt;When I execute this I get the following&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;index=*
| head 1
| eval mystring = "hello"
| lookup mylookup mystring
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I get" Script execution failed for external search command '/opt/splunk/etc/apps/TA-myapp/bin/mylookup.py'."&lt;/P&gt;
&lt;P&gt;here is my python.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;#!/usr/bin/env python

import csv
import sys


def main():

    if len(sys.argv) != 3:
        print("Usage: python mylookup.py [mystring] [myoutput]")
        sys.exit(1)

    # always passing hello as a eval mystring = "hello"
    mystring = sys.argv[1]
    myoutput = sys.argv[2]

    infile = sys.stdin
    outfile = sys.stdout

    r = csv.DictReader(infile)
    header = r.fieldnames

    w = csv.DictWriter(outfile, fieldnames=r.fieldnames)
    w.writeheader()

    for result in r:
            result[mystring] = "hello"
            result[myoutput] = "world"
            w.writerow(result)

main()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Jun 2020 18:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Doing-my-first-scripted-lookup-trying-a-basic-hello-world-where/m-p/460239#M8375</guid>
      <dc:creator>daniel333</dc:creator>
      <dc:date>2020-06-07T18:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Doing my first scripted lookup, trying a basic hello world ... where do I start?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Doing-my-first-scripted-lookup-trying-a-basic-hello-world-where/m-p/460240#M8376</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Have you configured transforms.conf for external lookup ?&lt;/P&gt;

&lt;P&gt;Like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mylookup]
external_cmd = mylookup.py mystring
fields_list = mystring,myoutput
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Mar 2020 10:37:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Doing-my-first-scripted-lookup-trying-a-basic-hello-world-where/m-p/460240#M8376</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2020-03-27T10:37:19Z</dc:date>
    </item>
  </channel>
</rss>

