• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sending Commands to Terminal Windows
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending Commands to Terminal Windows


  • Subject: Re: Sending Commands to Terminal Windows
  • From: Christopher Nebel <email@hidden>
  • Date: Sat, 24 Aug 2002 21:34:56 -0700

On Saturday, August 24, 2002, at 08:43 PM, Jeffrey Berman wrote:

...while you still can't issue a command and respond to a prompt in one shot, you can do it in two:

do script "slogin somewhere.com"
do script "password" -- types the password.

Would there need to be an "in" parameter for the second line to avoid
spawning a new window?

Oh, duh. Yes, of course there is. That's what I get for typing it in by hand instead of using copy and paste. : \

Having tried it for real now, I find that what works well is to let the first command spawn a new window, and then use "in window 1" for the rest, since the spawned window is created frontmost. (I suppose if you're being paranoid, you should get window 1 immediately after the first command, stuff it in a variable, and use that. That way, you won't be sensitive to people re-ordering windows while the script is running.)

Also, and this is irritating but not surprising and may depend on the command, login sequences like this are sensitive to timing. You'll probably need a "delay" statement between the initial command and the password.

Putting that all together, I can get a telnet session going using the following:

tell application "Terminal"
do script "telnet metropolis"
set w to window 1
delay 5
do script "nebel" in w
delay 1
do script "password" in w -- no, my password isn't really "password".
end tell


--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Sending Commands to Terminal Windows (From: Jeffrey Berman <email@hidden>)

  • Prev by Date: Re: Sending Commands to Terminal Windows
  • Next by Date: Re: Running Subroutines from Other Scripts
  • Previous by thread: Re: Sending Commands to Terminal Windows
  • Next by thread: Re: Sending Commands to Terminal Windows
  • Index(es):
    • Date
    • Thread