4

I'm trying to write a short shell script to open a new terminal window and launch a program. Here is what I have:

osascript <<END
tell application "Terminal"
    make new window
    activate
    set contents of window to "./hello" & return
end tell
END

execution error: Terminal got an error: AppleEvent handler failed. (-10000)

Can anyone tell me how to do this? In a perfect world, I'd also like this script to run on Linux, so if there is a method that will be portable, that would be preferable.

Thank you!

2 Answers 2

5

The do script command runs a command in a new Terminal window:

osascript -e 'tell app "Terminal" to do script "uptime"'
Sign up to request clarification or add additional context in comments.

Comments

1

something like this :

 osascript<<EOF
tell application "System Events"
  tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
  activate
  do script with command "./hello" in window 1
end tell
EOF

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.