Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 6, 2006, 08:13 AM   #1
jaxstate
Banned
 
Join Date: Apr 2006
AppleScript telnet command

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.
jaxstate is offline   0 Reply With Quote
Old Jul 6, 2006, 08:31 AM   #2
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Wouldn't it be better to use SSH as it's secure? I don't have my Mac at the moment but
Code:
do shell script "telnet username@ip-address"
should work.
__________________
Actually it does make sense. Man created god, so if we exist, He exists. - obeygiant
Eraserhead is offline   0 Reply With Quote
Old Jul 6, 2006, 08:52 AM   #3
jaxstate
Thread Starter
Banned
 
Join Date: Apr 2006
Once I telnet into the router, I'm going to issue terminal commands for a code upgrade for the router.
Quote:
Originally Posted by Eraserhead
Wouldn't it be better to use SSH as it's secure? I don't have my Mac at the moment but
Code:
do shell script "telnet username@ip-address"
should work.
jaxstate is offline   0 Reply With Quote
Old Jul 6, 2006, 10:44 AM   #4
jaxstate
Thread Starter
Banned
 
Join Date: Apr 2006
Figured it out. Now on to another can of worms!! I'm really lovin applescript so far.
jaxstate is offline   0 Reply With Quote
Old Jul 6, 2006, 10:46 AM   #5
yellow
Moderator
 
yellow's Avatar
 
Join Date: Oct 2003
Location: Portland, OR
Quote:
Originally Posted by jaxstate
Figured it out.
Can you please detail the "fix" in case other people have the same question and come across this thread?
yellow is offline   0 Reply With Quote
Old Jul 6, 2006, 11:59 AM   #6
jaxstate
Thread Starter
Banned
 
Join Date: Apr 2006
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.

Last edited by jaxstate; Jul 6, 2006 at 12:14 PM.
jaxstate is offline   0 Reply With Quote
Old Jul 6, 2006, 03:24 PM   #7
jaxstate
Thread Starter
Banned
 
Join Date: Apr 2006
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.
jaxstate is offline   0 Reply With Quote
Old Jul 6, 2006, 04:43 PM   #8
HexMonkey
Administrator
 
HexMonkey's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Try "\\x14" instead. '\' is a special character so you need to escape it to use it normally.
HexMonkey is offline   0 Reply With Quote
Old Jul 6, 2006, 04:49 PM   #9
jaxstate
Thread Starter
Banned
 
Join Date: Apr 2006
Thanks, that worked. Off to the next problem.
Quote:
Originally Posted by HexMonkey
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.

Last edited by jaxstate; Jul 6, 2006 at 09:02 PM.
jaxstate is offline   0 Reply With Quote
Old Jul 6, 2006, 10:03 PM   #10
wala
macrumors member
 
Join Date: Jun 2005
It's in the documentation for System Events:

Code:
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.

Last edited by wala; Jul 10, 2006 at 02:04 PM.
wala is offline   0 Reply With Quote
Old Jul 14, 2006, 03:58 PM   #11
jaxstate
Thread Starter
Banned
 
Join Date: Apr 2006
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 is offline   0 Reply With Quote
Old Jul 14, 2006, 04:36 PM   #12
jaxstate
Thread Starter
Banned
 
Join Date: Apr 2006
for anyone who would like to know it's

set CL to ASCII character 20

where CL is just some variable
jaxstate is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
OS-neutral: Telnet/Text adventure games Astroboy907 Mac and PC Games 8 Feb 23, 2014 12:27 PM
HELP Applescript for telnet SOOMINAHN Mac Programming 1 Feb 10, 2013 07:45 PM
vSSH - SSH and Telnet client for Mac OS X Velestar Mac Applications and Mac App Store 0 Feb 1, 2013 04:09 AM
Very basic Applescript to run command bjbyers Mac Programming 1 Nov 27, 2012 03:03 PM
Xcode telnet code MagicJordan iPhone/iPad Programming 0 Oct 8, 2012 05:01 PM

Forum Jump

All times are GMT -5. The time now is 01:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC