Wow, been a busy month, almost non-stop.
However I am now able to catch up with projects I wanna do. One was fix an issue with PyConnect.
PyConnect is a great system to connect Plex Server to the families three AppleTV boxes. Long and short it changes the Trailers channel into your Plex Server Channel. And it is easy enough for everyone to use.
However when the power goes out (normal here during rainy season), the kids would have to wait till I get home and re-run the script. The script would asked for admin password. Not something I am willing to hand over to the kids yet.
So after some googling this is what I came up with:
set sshPasswd to “supergeek1”
try
tell application “Terminal”
quit
end tell
on error
end try
tell application “Terminal”
activate
my execCmd(“cd /Applications/PlexConnect-Master”, 1)
my execCmd(“set timeout 30”, 1)
my execCmd(“expect -c ‘spawn sudo ./PlexConnect.py; expect \”*?assword:*\”; send \”&sshPassword&\”; interact’;”, 1)
end tell
on execCmd(cmd, pause)
tell application “System Events”
tell application process “Terminal”
set frontmost totrue
keystroke cmd
keystroke return
end tell
end tell
delay pause
end execCmd
This was written in Applescript, saved as an Application bundle, and added to the startup items. Noticed if I didn’t quit terminal first, all the system would do is make a few clicking noises and pyconnect wouldn’t start.
It also has the added bonus of not displaying the password, and you still get the terminal activity window to monitor usage.
Not bad for an afternoon’s playing.
Enjoy
~David