AppleScript telnet command

Discussion in 'Mac Programming' started by jaxstate, Jul 6, 2006.

  1. macrumors 6502a

    Joined:
    Apr 13, 2006
    #1
    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.
     
  2. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    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.
     
  3. thread starter macrumors 6502a

    Joined:
    Apr 13, 2006
    #3
    Once I telnet into the router, I'm going to issue terminal commands for a code upgrade for the router.
     
  4. thread starter macrumors 6502a

    Joined:
    Apr 13, 2006
    #4
    Figured it out. Now on to another can of worms!! I'm really lovin applescript so far.
     
  5. Moderator emeritus

    yellow

    Joined:
    Oct 21, 2003
    Location:
    Portland, OR
    #5
    Can you please detail the "fix" in case other people have the same question and come across this thread?
     
  6. thread starter macrumors 6502a

    Joined:
    Apr 13, 2006
    #6
    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.
     
  7. thread starter macrumors 6502a

    Joined:
    Apr 13, 2006
    #7
    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.
     
  8. Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #8
    Try "\\x14" instead. '\' is a special character so you need to escape it to use it normally.
     
  9. thread starter macrumors 6502a

    Joined:
    Apr 13, 2006
    #9
    Thanks, that worked. Off to the next problem.
    Do anyone, i mean anyone know the command for "Ctrl t" for applescript.:(
     
  10. macrumors member

    Joined:
    Jun 3, 2005
    #10
    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.
     
  11. thread starter macrumors 6502a

    Joined:
    Apr 13, 2006
    #11
    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!
     
  12. thread starter macrumors 6502a

    Joined:
    Apr 13, 2006
    #12
    for anyone who would like to know it's

    set CL to ASCII character 20

    where CL is just some variable
     

Share This Page