PDA

View Full Version : AppleScript telnet command




jaxstate
Jul 6, 2006, 08:13 AM
Hello, I'm trying to write my first applescript, and i'm already at a loss. Can anyone give the syntax to do a simple telnet. I have a IP address that I want to telnet into, but keep getting a "expect a " not a ." error. Any help will be useful.



Eraserhead
Jul 6, 2006, 08:31 AM
Wouldn't it be better to use SSH as it's secure? I don't have my Mac at the moment but do shell script "telnet username@ip-address" should work.

jaxstate
Jul 6, 2006, 08:52 AM
Once I telnet into the router, I'm going to issue terminal commands for a code upgrade for the router.
Wouldn't it be better to use SSH as it's secure? I don't have my Mac at the moment but do shell script "telnet username@ip-address" should work.

jaxstate
Jul 6, 2006, 10:44 AM
Figured it out. Now on to another can of worms!! I'm really lovin applescript so far.

yellow
Jul 6, 2006, 10:46 AM
Figured it out.

Can you please detail the "fix" in case other people have the same question and come across this thread?

jaxstate
Jul 6, 2006, 11:59 AM
This is the simple code i'm using to telnet into my IAD router.

set telnet to "telnet 10.7.6.17"
set username to "router1"
set password to "macrumors"
tell application "Terminal"
run
do script telnet
delay 1
do script username in window 1
delay 1
do script password in window 1
end tell

now I have to get to find out how to do "cntrl -t" to get to the terminal menus in this router.

jaxstate
Jul 6, 2006, 03:24 PM
OK i'm at a lost again. Do anyone know how to send "\x14" using applescript. Everytime I try sending it, Script Editor sends me a "Expected " but found unknow token" syntax error.

HexMonkey
Jul 6, 2006, 04:43 PM
Try "\\x14" instead. '\' is a special character so you need to escape it to use it normally.

jaxstate
Jul 6, 2006, 04:49 PM
Thanks, that worked. Off to the next problem.
Try "\\x14" instead. '\' is a special character so you need to escape it to use it normally.
Do anyone, i mean anyone know the command for "Ctrl t" for applescript.:(

wala
Jul 6, 2006, 10:03 PM
It's in the documentation for System Events:

tell application "System Events"
tell application "Terminal" to activate
keystroke "t" using control down
end tell

Or something like that...
If you're looking for a signal like "^T" then I don't think one exists, and ctrl-t seems to do nothing in Terminal, and Command-t brings up the font selector.

EDIT: Control-t transposes characters when editing fields.

jaxstate
Jul 14, 2006, 03:58 PM
Thanks, I'll give it a try.

F.Y.I, I did a google search for "Ctrl T in applescript" and this thread was the top hit!

jaxstate
Jul 14, 2006, 04:36 PM
for anyone who would like to know it's

set CL to ASCII character 20

where CL is just some variable