Prevent macos automator Terminal ssh script from opening two windows

45 Views Asked by At

I use a small macOS Automator script to ssh into a remote host so I can add it to the Dock:

tell application "Terminal"
    activate
    do script ("ssh [email protected];")
end tell

When used the first time, I get the expected remote Terminal window, but also an extra local Terminal window. All subsequent uses only generate a single window to the remote host.

I've tried some small alternatives like:

set currentWindow to do script...

and:

set currentTab to do script...

with the same result. Is there any way to prevent the initial local Terminal window?

1

There are 1 best solutions below

0
Robot On

I found a post that has the answer:

tell application "Terminal"
    if not application "Terminal" is running then launch
    do script ("ssh [email protected];")
    activate
end tell