I would like to check if a program is running,
if not, launch (which automatically opens a new window)
if running, then is there an open window
if not, open window
if open window, use window
Here’s my script, but it fails if a window is not open.
tell application "Terminal"
launch
repeat with theWindow in window 1
do script "rsync -avz -e ..." in theWindow
do script "passwd" in theWindow
do script "exit" in theWindow
end repeat
end tell