In my Mac, how do I write a script that can do this?
- Open "terminal".
- In that terminal, "ssh myserver"
- Open a new "tab" inside the terminal.
- In that tab, "ssh myserver2"
Then, how would I run this script?
Save as script or application. Anytime you execute, Terminal will be brought to front (started if necessary), and two new tabs will be created for your SSH sessions.
In this answer I outlined how to check whether a window is already open (without an application running) to prevent opening one tab/window too many.
You can create a Window Group to make it convenient to recreate windows and tabs, and you can use Settings profiles to issue ssh commands when windows/tabs are created.
Now, whenever you want to recreate that window and start the ssh sessions, choose Window > Open Window Group > [your group].
You can also tell Terminal to open the window group every time you start Terminal (Terminal > Preferences > Startup > On startup, open: > Window group:).
Use iTerm 2 (scroll down to profiles)