Re: Sending Commands to Terminal Windows
Re: Sending Commands to Terminal Windows
- Subject: Re: Sending Commands to Terminal Windows
- From: Christopher Nebel <email@hidden>
- Date: Sat, 24 Aug 2002 20:22:55 -0700
On Thursday, August 22, 2002, at 04:51 PM, Jeffrey Berman wrote:
On 8/21/02 6:48 PM, Jeffrey Berman <email@hidden> wrote:
Two questions:
1. Is there a way to use AppleScript to send line commands to a
Terminal
window with an already open connection?
2. Can you use AppleScript to issue commands to a new Terminal window
to
connect and login to a remote host? When I naively tried:
tell application "Terminal"
do script with command ("slogin <host address>" & return &
"<password>" &
return)
end tell
it opened a new connection but stopped at the remote host password
prompt.
Does the absence of a response to these questions mean that neither
action
can be accomplished with AppleScript?
No, it means you've got to be patient. Now that 10.2 has officially
shipped, I can give you the complete answer to your question:
Neither (1) nor (2) is possible in 10.1.x -- "do script" always spawns
a new window, and because of how terminal input works, you can't issue
a command and respond to a prompt it puts up in a single command.
Terminal in 10.2 redefines the "do script" command a bit. First --
this is incidental to your question, but I wanted to mention it -- it
now lets you give the command as the direct parameter, so you can just
say 'do script "ls"' without that stupid "with command" parameter.
("with command" still works, but it's deprecated now. It was only
necessary because of a now-lifted restriction in Cocoa Scripting.)
Second -- and this *is* relevant -- there's now an "in" parameter which
takes a window. If you leave it off, you'll get the old
spawn-a-new-window behavior, but if you say "in window <whatever>",
it'll use that window. The other cool bit is that it really just
treats the "command" as input, so 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.
--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.