check if terminal is busy running a script on another server

I’m trying to find a way to tell if termianal is actively running a script on a FreeBSD server. I use Applecript to do an SSH connection and then have the FeeeBSD server run a script which takes about 2-3mins. I basically want to find when that script has completed
The problem is that a ‘is terminal busy’ does not appear to work.


set isBusy to true
repeat until isBusy is false
	tell application "Terminal"
		tell window 1
			set isBusy to busy as boolean --> Test if busy 
		end tell
	end tell
	delay 1 --> Check every second 
end repeat

after all the script is done on the FreeBSD server rather than on the Mac.

I’d be interested if I could ‘read’ the terminal window once it has returned to a prompt and is waiting for the next input.
The way I do it currently do it is to capture the screen and try to spot for a complete page of output from the terminal window (including all the blank space) but this is dependant on the window size remaining unaltered.
any ideas?

better late than never

set isBusy to true
repeat until isBusy is false
	tell application "Terminal"
		tell window 1
			if name contains "bash" then
				set isBusy to false
			end if
			--	set isBusy to busy as boolean --> Test if busy 
		end tell
	end tell
	delay 1 --> Check every second 
end repeat

Definately better late than never!! In fact your timing was impeccable.
The scipt was giving me more problems after Tiger update.
I did however amend your suggestion a little - and seems to work a treat.

I didn’t know AS cou;d do ‘contents contains’ which is down to my inexperience. I probably don’t need the size of the term window set, and the title doesn’t change on completion of the remote script.
Thanks for your help.

set isBusy to true
	repeat until isBusy is false
		tell application "Terminal"
			tell window 1
				set number of columns to 80
				set number of rows to 40
				if contents contains "samba# sh backup

 
samba#" then
					set isBusy to false
				end if
				--    set isBusy to busy as boolean --> Test if busy 
			end tell
		end tell
		delay 1 --> Check every second 
	end repeat