Page 2 of 2

Re: Issue ADB Command from Indigo

PostPosted: Sun Dec 02, 2018 7:39 pm
by johnfdl
I might be in over my head......unsure how to write a shell script (not sure what tool to write it with or what the syntax would be). I might just keep the applescript I have working....since that works just fine and I assumed it would be a simple thing to convert to python.

Re: Issue ADB Command from Indigo

PostPosted: Mon Dec 03, 2018 9:44 am
by jay (support)
Simple. Insert this stuff into a file:

Code: Select all
#!/bin/bash
/path/to/adb connect 192.168.2.91
/bin/sleep 2
/path/to/adb shell input keyevent KEYCODE_MEDIA_PLAY_PAUSE
/path/to/adb disconnect


Substitute /path/to/ with the actual path to the adb command. Name the file something like playpause.sh (you can use any plain text editor). This script includes a sleep that mirrors the delay in your AppleScript in case it's necessary for some reason (it may not be needed but you can determine that).

Then, in a terminal window in the same directory as the script file, issue the following command:

Code: Select all
bash ./playpause.sh


Basically, a shell script is just a series of shell commands in a single file and executed serially. So, it mimics what you type into a terminal window (we add the full paths so that the shell script isn't dependent on specific paths set in the environment).

If that works, then you're good to point the Run Shell Script action at that file.

Re: Issue ADB Command from Indigo

PostPosted: Mon Dec 03, 2018 6:54 pm
by johnfdl
Thanks Jay. I'm familiar with bat files on Windows, but relatively new to Mac. So even some basic things just elude me (even though I'd have no issue understanding how to do on a PC). Anyway.....just didn't want you thinking i was an idiot, but also didn't want to 'tax' you guys with excessive handholding.

So I put your command in a file with a .sh extension and ran it from the terminal window....it worked perfectly.

I then went to update the action group in Indigo to use the script file as follows:
Image

But when I execute it from within Indigo, the log shows an error as follows:
Dec 3, 2018 at 7:42:52 PM
Action Group Test Python call to FireTV
Action Collection Error Couldn't run script - make sure the script is marked executable and contains a valid shebang on the first line


Do I have the path syntax correct? I mean, I know it's the right path, but again, I am a windows guy, so unsure if it is something like /Users/MacUser/Downloads/bash ./playpause.sh (though I tried that too without success).

Re: Issue ADB Command from Indigo

PostPosted: Tue Dec 04, 2018 11:35 am
by jay (support)
Sorry, left out one step - in a terminal window:

Code: Select all
chmod +x /Users/MacUser/Downloads/playpause.sh


That will mark it as an executable script file.

Re: Issue ADB Command from Indigo

PostPosted: Wed Dec 05, 2018 2:57 pm
by johnfdl
Thanks. So after I entered the terminal command to make it executable, it no longer produces an error, but it also doesn't seem to execute the script in that the TV doesn't pause. It works well I call the script in terminal, though. The Event Log shows no error:

Dec 5, 2018 at 3:43:24 PM
Action Group Test Message from Indigo

No terminal window appears when I execute the ActionGroup and the desired effect does not happen like when I execute it from the terminal command.

Re: Issue ADB Command from Indigo

PostPosted: Thu Dec 06, 2018 3:58 pm
by jay (support)
Post the exact contents of the shell script in Code tags please.

Re: Issue ADB Command from Indigo

PostPosted: Thu Dec 06, 2018 4:02 pm
by johnfdl
Code: Select all
#!/bin/bash
adb connect 192.168.2.91
/bin/sleep 2
adb shell input keyevent KEYCODE_MEDIA_PLAY_PAUSE
adb disconnect


Odd that it works when I call the script file in terminal window, but not when it's called from Indigo. I certainly appreciate the assist on this, but I totally understand if there are more pressing issues that require your attention.

Re: Issue ADB Command from Indigo

PostPosted: Thu Dec 06, 2018 4:10 pm
by jay (support)
You must specify the full path to the adb command as in my example above - when Indigo executes the shell script it has a different shell environment than when you open a terminal window.

Re: Issue ADB Command from Indigo

PostPosted: Thu Dec 06, 2018 4:19 pm
by matt (support)
To find the full path to adb copy/paste this into Terminal:

which adb

Re: Issue ADB Command from Indigo

PostPosted: Thu Dec 06, 2018 6:25 pm
by johnfdl
Thanks. That was it. I appreciate the help from everyone!