sending text to terminal

is there a way to simply send text to an open terminal window? basically, what i have is this:
tell application “Terminal”
activate
do script with command “ssh my.domain.com
–close the other blank original window
close window 2
end tell

i’d like to send my password (it’s not a security risk in this instance) when ssh asks for it, then a command once i get a prompt on the remote system. is this at all possible?

i know i could use ssh-agent but i’d prefer not to for a few reasons.

just tell teminal where you want the text to be entered:

tell application “terminal”
do script “myPassword” in window 1
end tell

will type ‘myPassword’ in the frontmost window.

thanks, this helped a lot. i found it necessary to add “delay 10” so that it would wait for the connection to happen, but after that it worked fine. thanks for helping with the newbie question.

if i had previously asked for the password in a dialog box, is there an easy way to send that to terminal? i.e., if i used something like this (stolen from an example apple.com script):


-- Ask the user for the password for their email account
on getPassword()
	set theResult to display dialog "What is the password for this account?" default answer ""
	set thePassword to text returned of theResult
	return thePassword
end getPassword

could i tell terminal to use the defined variable instead of the actual text? something like this?


tell application "terminal" 
  do script " % thePassword % " in window 1 
end tell 

this code just gives an error…i’m just not sure how to mix text and variables and am still very new to all of this. my applescript looks great, but i want to make it so that others can use it–i.e., my username and passoword aren’t permanently defined in the script.

thanks for any help.