Setting a specific Terminal window to be the frontmost

I’m running in Leopard (10.5.5), and I want to write an AppleScript program to find a specific Terminal window out of several that might be running, and if that one is found, to make it be the frontmost one. I know how to use Finder within my AppleScript to locate Terminal documents, but I don’t know how distinguish between them.

Specifically, I want to find the Terminal window in which a certain shell command has been started.

Can anyone suggest a way to find a Terminal window that is running a specific command, so I can then tell Finder to make it frontmost?

Thanks in advance.

Hello.

I have tried this, and it works for me, as long as I put an activate command before the repeat with line. Without activate, the set frontmost command doesn’t move the terminal window to the front of all the windows on my screen. It just makes it the frontmost of all the Terminal windows.

Thank you!