Terminal Question

How do you get applescript to run a certain script inside the terminal, as in.

tell application "Terminal"
	activate
	do shell script "."
end tell

.but have the script actually run inside the terminal so you can see what is happening?

Do shell script is part of StandardAddtions. To script the Terminal, use it’s ˜do script’ command.

tell application "Terminal"
	activate
	do script "."
end tell

hi m, bruce,

if you run that, you’ll get 2 Terminal windows. this will get you just one:

tell application "Terminal"
	do script "/bin/echo \"Hello, I'm the Terminal\""
end tell

EDITED: i spoke wrong. it will only get you 2 terminal windows if Terminal is not running. if Terminal is running you get one. my way gets one window every time.

Waltr, ˜do script’ makes a new window by default. If you want ˜do script’ to use a specific window, you can tell it that.

tell application "Terminal"
	activate
	do script "." in window 1
end tell

Of course, that won’t work if no windows exist, so you may want to make sure one exists:

tell application "Terminal"
	activate
	if (count windows) is 0 then do script ""
	
	do script "echo Hello" in window 1
end tell

Edit: Here’s a somewhat related thread: Sending a command to Terminal, via applescript

thanks a lot for your help

:slight_smile: