Issue ADB Command from Indigo

Posted on
Sun Dec 02, 2018 7:39 pm
johnfdl offline
Posts: 132
Joined: May 18, 2017
Location: Atlanta, GA USA

Re: Issue ADB Command from Indigo

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.

Posted on
Mon Dec 03, 2018 9:44 am
jay (support) offline
Site Admin
User avatar
Posts: 15477
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Issue ADB Command from Indigo

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 03, 2018 6:54 pm
johnfdl offline
Posts: 132
Joined: May 18, 2017
Location: Atlanta, GA USA

Re: Issue ADB Command from Indigo

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).

Posted on
Tue Dec 04, 2018 11:35 am
jay (support) offline
Site Admin
User avatar
Posts: 15477
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Issue ADB Command from Indigo

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Dec 05, 2018 2:57 pm
johnfdl offline
Posts: 132
Joined: May 18, 2017
Location: Atlanta, GA USA

Re: Issue ADB Command from Indigo

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.

Posted on
Thu Dec 06, 2018 3:58 pm
jay (support) offline
Site Admin
User avatar
Posts: 15477
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Issue ADB Command from Indigo

Post the exact contents of the shell script in Code tags please.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Dec 06, 2018 4:02 pm
johnfdl offline
Posts: 132
Joined: May 18, 2017
Location: Atlanta, GA USA

Re: Issue ADB Command from Indigo

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.

Posted on
Thu Dec 06, 2018 4:10 pm
jay (support) offline
Site Admin
User avatar
Posts: 15477
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Issue ADB Command from Indigo

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Dec 06, 2018 4:19 pm
matt (support) offline
Site Admin
User avatar
Posts: 19135
Joined: Jan 27, 2003
Location: Texas

Re: Issue ADB Command from Indigo

To find the full path to adb copy/paste this into Terminal:

which adb

Image

Posted on
Thu Dec 06, 2018 6:25 pm
johnfdl offline
Posts: 132
Joined: May 18, 2017
Location: Atlanta, GA USA

Re: Issue ADB Command from Indigo

Thanks. That was it. I appreciate the help from everyone!

Who is online

Users browsing this forum: No registered users and 1 guest