Problems running a bash script

Ask questions about integrating other services (internet and otherwise) and applications with Indigo.
vtmikel
Posts: 648
Joined: Fri Aug 31, 2012 12:45 pm
Location: Boston, MA
Contact:

Problems running a bash script

Post by vtmikel »

Hi all-

I'm scratching my head trying to solve this. I this script working fine, executed by an Indigo Action. I re-installed MacOS with a clean install as I was migrating to a new Z-wave interface (old one was acting weird). I'm up and running on my new setup, but the script is not working.

The script sends a command to a broadlink RF blaster that controls my basement door opener. The script is static, no parameters.

Permissions on the bash script, and the cli binary are 777 to be safe. The @Door.auto file (which contains the full command to send to the RF relay) is permissions 666.

When I run the script from the Terminal of the Indigo Mac, it works just fine. But, executing in Indigo, nothing happens and there's no useful error.

Is there a higher level of log that I can set to get more useful information on what's going on?

Script:

Code: Select all

#!/bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

cd $SCRIPT_DIR
$SCRIPT_DIR/broadlink_cli/broadlink_cli --type 0x61a2 --host xxxxxxx --mac yyyyyyy --send @Door.auto
Indigo Log:

Code: Select all

   Action Group                    00 - Basement Server Area Door - Auto Close
   Action Collection Error         Run Shell Script action: script /Users/mike/Documents/indigo-scripts/auto_basement_door_auto.sh exited abnormally with a return code of: 1
User avatar
DaveL17
Posts: 6903
Joined: Tue Aug 20, 2013 11:02 am
Location: Chicago, IL, USA
Contact:

Re: Problems running a bash script

Post by DaveL17 »

One thing you might try is running the script from within Python using subprocess.run() (from within an Indigo action) and collect stdout and stderr to see if anything is useful there. IIRC, you can also send the result of the bash script execution to an Indigo variable so that might also provide some insights.

Code: Select all

import subprocess

result = subprocess.run(['bash', 'your_script.sh'], capture_output=True, text=True)
if result.returncode == 0:
    print("Script executed successfully")
else:
    indigo.server.log(f"{result.returncode}")
    indigo.server.log(f"stdout: {result.stdout}")
    indigo.server.log(f"stderr: {result.stderr}")
I came here to drink milk and kick ass....and I've just finished my milk.

My Plugins and Scripts
User avatar
FlyingDiver
Posts: 7355
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Problems running a bash script

Post by FlyingDiver »

Trying in the Plugin scripting shell would also be useful.
joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177
Post Reply

Return to “Integrating Services/Applications”