Python? version error trying to run shell script

Posted on
Sun Jan 23, 2022 11:45 am
tornado offline
User avatar
Posts: 102
Joined: Jun 30, 2014

Python? version error trying to run shell script

Hello,

I can execute this command via the terminal on the host Mac:

Code: Select all
/Users/tornado/Dropbox/dev/active/python-broadlink/cli/broadlink_cli

using python version 3.9.9 (main, Nov 21 2021, 03:16:13)
[Clang 13.0.0 (clang-1300.0.29.3)]


It works just fine. When I try to "Execute Shell Script" on that script via Indigo I get:
Code: Select all
   Action Group                    Broadlink: Candle Off
   Action Collection Error         Run Shell Script action: script /Users/tornado/Dropbox/dev/active/python-broadlink/cli/broadlink_cli exited abnormally with a return code of: 1


The top of my shell script is currently this:
Code: Select all
#!/usr/bin/env python3
import sys

print("using python version ", (sys.version))
exit()


Any suggestions as to why it complains?

Thanks!
Joe

Posted on
Sun Jan 23, 2022 12:16 pm
jay (support) offline
Site Admin
User avatar
Posts: 18185
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python? version error trying to run shell script

Remove the last line (exit()) and try it then. exit() is used specifically by the python interpreter, but we don't use the standard one, so exit() is likely failing. But you don't need it at all given that it's the last line of the script...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Jan 23, 2022 3:27 pm
tornado offline
User avatar
Posts: 102
Joined: Jun 30, 2014

Re: Python? version error trying to run shell script

Thanks Jay.

I suppose I should be more verbose in actually what I'm doing and seeing. I had cut out a bunch of the script to try to boil it down to the issue but I may have confused things. This is actually the broadlink cli script. I'm trying to run the (full) script with parameters. This is what I'm putting in the Configure Run Shell Script:

Code: Select all
/Users/tornado/Dropbox/dev/active/python-broadlink/cli/broadlink_cli --host 10.0.1.30 --mac a043b0b8f751 --type 0x6539 --send 2600c800290d2a0d0d2a0d2a0e290e290f282a0d2a0d290e2a0d29eb290e2a0d0e290e290e290e290e292a0d2a0d290e2a0d2a00010d2a0e280f0d2a0e290e290e290e292a0d2a0d2a0d2a0d2ae92a0d2a0d0f280e290f280f280f292a0d2a0d290e280f2900010e2a0d290e0e290f280f280f280f282a0d2a0d2a0d2a0d2aea2a0d2a0d0e290e290e290e290e292a0d290e2a0d2a0d2a00010e2a0d2a0d0e290e290e290e290e292a0d2a0d2a0e280e2ae92a0e280f0d2a0d2a0d2a0e290d2a2a0d2a0d2a0d2a0d29000d05


When I run that command on the command line it works just fine and produces no output:
Code: Select all
tornado@macmini:~/Dropbox/dev/active/python-broadlink/cli% ./broadlink_cli --host 10.0.1.30 --mac a043b0b8f751 --type 0x6539 --send 26000201290e0d2a0d2a0e290e290f280f280f280f282a0e0e0001052a0d290e0e290e290f280e290f280e290e290f292a0d0e0001292a0d2a0d0e290f280f280e290f280f280f290e29290e0e000105290e290e0e290e290e290f280f280f280f280f282a0d0e00012a2a0d2a0d0e290e290e290d2a0e290e290e290f282a0d0f0001042a0e290e0d2a0e290e290e290d2a0e290e290e29290e0d00012a290e2a0d0f280e290f280e290f280f280f290e292a0d0e0001052a0d2a0d0e290e290d2a0e290e290f280f280f282a0d0f0001292a0d2a0d0e290d2a0e290e290e290e290e290e292a0d0f0001042a0d2a0d0f280f280f290e290e290e290e290e292a0d0d000d05
tornado@macmini


But when I put it in the Run Shell Script it doesn't work and I get:
Code: Select all
   Action Collection Error         Run Shell Script action: script /Users/tornado/Dropbox/dev/active/python-broadlink/cli/broadlink_cli exited abnormally with a return code of: 1


Any suggestions on what I'm doing wrong or how to debug?

Thanks.

Posted on
Mon Jan 24, 2022 10:22 am
jay (support) offline
Site Admin
User avatar
Posts: 18185
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python? version error trying to run shell script

When a command line app returns a non-zero value, it's considered an error. While your script doesn't print anything when run from the command line, it is in fact returning an exit code. I'd wrap your command line call in a separate script (to catch the return code) then exit the script normally.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Jan 24, 2022 1:24 pm
tornado offline
User avatar
Posts: 102
Joined: Jun 30, 2014

Re: Python? version error trying to run shell script

Thanks.

I ended up getting this going by using this shebang:

Code: Select all
#!/opt/homebrew/bin/python3


The clue was in console.log. I was getting this:

Code: Select all
Failed to open macho file at /Applications/Xcode.app/Contents/Developer/usr/bin/python3 for reading: Too many levels of symbolic links


Take care,
Joe

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest

cron