<?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: Shell script won't execute a Python script. in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32774#M379</link>
    <description>&lt;P&gt;When attempting to call a python script from a script, don't attempt to execute it directly using ./, instead call the interrupter to execute it for you. Something like this should suffice: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash

SCRIPT_PATH="myPythonscript.py" 
PYTHON="/usr/bin/python"

# call script via the interrupter     
$PYTHON $SCRIPT_PATH
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also make sure that the permissions are right on both scripts (chmod +x) etc. &lt;/P&gt;</description>
    <pubDate>Sat, 21 Apr 2012 09:50:26 GMT</pubDate>
    <dc:creator>abnev</dc:creator>
    <dc:date>2012-04-21T09:50:26Z</dc:date>
    <item>
      <title>Shell script won't execute a Python script.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32772#M377</link>
      <description>&lt;P&gt;I am totally confused after many hours of trying to figure this out and I couldn't find any other posts similar enough to my problem. Here's my problem:&lt;/P&gt;
&lt;P&gt;I want an alert to call a shell script (myShellScript.sh)&lt;/P&gt;
&lt;P&gt;I then want myShellScript.sh to execute a Python script (myPythonScript.py) in the same directory.&lt;/P&gt;
&lt;P&gt;myShellScript.sh looks like:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;#!/bin/bash&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;./myPythonScript.py&lt;/P&gt;
&lt;P&gt;myPythonScript.py looks like:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;#!/usr/bin/env python&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;::python code here::&lt;/P&gt;
&lt;P&gt;If I execute the shell script from the terminal it works. If I put in a shell script that doesn't try to run an executable into a Splunk alert message it works, but a sheel script that attempts to execute a command is a no-go. None of the logs (splunkd.log, scheduler.log, python.log) list any problems, the python executable has the proper permissions. Anybody know what's going on?&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 18:51:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32772#M377</guid>
      <dc:creator>jamaalsd</dc:creator>
      <dc:date>2020-06-07T18:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script won't execute a Python script.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32773#M378</link>
      <description>&lt;P&gt;You're assuming that the script's working directory is the path where it resides - however that's not the case. Scripts execute in the root path "/", so when you try to run "./myPythonScript.py" in the script that's equivalent to attempting to run "/myPythonScript.py".&lt;/P&gt;

&lt;P&gt;If you reference your Python script using its full path, or for that matter change your working directory at the start of the shell script, your script will work.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2012 08:51:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32773#M378</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-04-21T08:51:19Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script won't execute a Python script.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32774#M379</link>
      <description>&lt;P&gt;When attempting to call a python script from a script, don't attempt to execute it directly using ./, instead call the interrupter to execute it for you. Something like this should suffice: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/bin/bash

SCRIPT_PATH="myPythonscript.py" 
PYTHON="/usr/bin/python"

# call script via the interrupter     
$PYTHON $SCRIPT_PATH
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also make sure that the permissions are right on both scripts (chmod +x) etc. &lt;/P&gt;</description>
      <pubDate>Sat, 21 Apr 2012 09:50:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32774#M379</guid>
      <dc:creator>abnev</dc:creator>
      <dc:date>2012-04-21T09:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script won't execute a Python script.</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32775#M380</link>
      <description>&lt;P&gt;You should do it the other way round, run &lt;A href="http://net-informations.com/python/default.htm"&gt;python&lt;/A&gt; script inside screen:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;screen -dm bash -c 'script -c "python test.py" output.txt'
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 06:01:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Shell-script-won-t-execute-a-Python-script/m-p/32775#M380</guid>
      <dc:creator>murphybeck</dc:creator>
      <dc:date>2019-10-16T06:01:54Z</dc:date>
    </item>
  </channel>
</rss>

