Scripting waking up my (stupid) Smart TV

Hey guys,

I wrote applescript a lot for automating workflows in Adobe, but am admittedly very green when it comes to the command line.

My Sharp 70" TV (that acts only as a monitor for my Mac Mini) has IP control. It doesn’t accept SSH. It also requires commands come as 8 characters… It’s like that.

I’d like it to turn on when I tap any key on the Mac’s keyboard.

I’ve managed to find Scenario app, which can run scripts on display wake.

Now I need to telnet in, pause for a split second while it connects, then send the command.

Trouble is, I don’t know what I’m doing.

tell application “Terminal”
do script "telnet 192.168.1.123 10002; POWR1 "
"
delay 1
do script "POWR1 " in window 1
end tell

…is what I’m using now, but…

Last login: Mon Jan 30 22:50:21 on ttys000
TV:~ jordan$ telnet 192.168.1.123 10002
Trying 192.168.1.123…
Connected to 192.168.1.123.
Escape character is ‘^]’.

POWR1
OKR

…means that to close Terminal, I need to first enter that CTRL+], or press the “Terminate” button when it tries to close the window, or force quit. Scripting those options is asking for trouble, and proving it by functioning unreliably. I know I shouldn’t be using Terminal for shell commands anyway, so I come seeking guidance from your wisdom. Please help!

Thanks,
-J