Multiple Commands in Terminal

Hello,

beside the method to invoke several commands separated by a semicolon the following method works fine:

tell application "Terminal"
	do script "source ~/my_livecd_bashrc" in front window
	do script "chroot_gentoo" in front window
	do script "env-update" in front window
	do script "source /etc/profile" in front window
	do script "source ~/.bash_profile" in front window
end tell

Actually, is there a solution to invoke several lines without the redundancy “in front window”? Unvortunatelly, the following attempt doesn’t work for me. What’s wrong or is there another solution to avoid the redundancy?

tell application "Terminal"
	activate
	set myWindow to terminal in front window
	tell myWindow
		activate
		do script "ifconfig eth0"
		do script "hostname"
		do script "source ~/my_livecd_bashrc"
		do script "chroot_gentoo"
		do script "env-update"
		do script "source /etc/profile"
		do script "source ~/.bash_profile"
	end tell
end tell

Thank you in advance for any hint.

Cheers,

B.

Model: Mac Mini
Browser: Safari 533.18.5
Operating System: Mac OS X (10.6)

I think ‘terminal in front window’ is not good syntax.

With a Terminal window open, try this:

tell application "Terminal"
	windows--> {window id 539 of application "Terminal"}
end tell

then have the script talk to that.
Possibly ‘frontmost window’ may do the the trick, too.

HTH

Still no solution for this.

As far as ‘tell window 1’ or ‘tell front window’ works, it doesn’t for the ‘do script’ command.

The settings in the following example are applied in the front most window as desired:


set myBackgroundColor to {589, 0, 10747}
set myTextColor to {65535, 65535, 0}
set myCursorColor to {21823, 21823, 21823}

tell application "Terminal"
	
	tell front window
		set background color to myBackgroundColor
		set cursor color to myCursorColor
		set normal text color to myTextColor
	end tell
	
end tell

But it doesn’t in the following example issuing the ‘do script’ command:


tell application "Terminal"
	
	tell front window
		set background color to {15716, 0, 0, -10240}
		do script "echo FOO"
	end tell
	
end tell

While the background color changes the front window as expected, ‘do script’ invokes a new window to execute “echo FOO”.

Obviously, its mandatory to specify the target window if ‘do script’ should be executed in a particular Terminal window.

As the in parameter of the do script command is a ‘single relationship’ parameter,
you can’t use it with a tell or whatever wrapper

Stefan, many thanks for the “scientific” clarification why ‘do script’ doesn’t work in wrapper like contexts.