Used it just recently because I couldn't remember where a device console was connected.
Don't change mouse focus while it's running: It'll wind up dumping keystrokes into the wrong window.
for i in $(seq 48)
do
port=$(expr 3000 + $i)
sshcmd="ssh -p $port terminalserver"
osascript \
-e 'tell application "Terminal" to activate' \
-e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
-e "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"$sshcmd\"" \
-e "tell application \"System Events\" to tell process \"Terminal\" to key code 36"
done