1

I'm currently pulling my hair out trying to make an apple script execute a shell script / Unix executable, so that I can drag it into the dock. I don't have much experience with AS, so this is propably an easy fix for many of you guys.

Here's the whole script:

to run
    do shell script "/Users/MyUserName/Documents/cmus/2.7.1_1/bin/cmus"
end run

Cmus is a terminal music program that is a Unix executable.

When I try to run it, I get this error message:

error "Error opening terminal: unknown." number 1

What is the problem? Pls help...

7
  • What is the output of the command: echo $TERM? Commented Apr 1, 2016 at 10:42
  • I have no idea what you mean.. How do I check this? Commented Apr 1, 2016 at 10:42
  • Open Terminal.app and paste that command... it should output something. Commented Apr 1, 2016 at 10:43
  • xterm-256color <--- this is the output Commented Apr 1, 2016 at 10:46
  • Post more of your script... surely that's not all of it. Commented Apr 1, 2016 at 10:52

2 Answers 2

3

I am guessing your program is curses based and needs a Terminal window, so try this:

to run
   tell application "Terminal"
      do script "/Users/MyUserName/Documents/cmus/2.7.1_1/bin/cmus"
   end tell
end run
Sign up to request clarification or add additional context in comments.

9 Comments

That's a first! A down vote before I have even finished typing/checking my answer! And without any explanation - how very polite! NOT!
That's a fine attitude when I am trying to help someone. A simple, polite comment would have sufficed, and helped more.
I feel your pain, and completely agree... +1
@djbazziewazzie I agree that truly awful, grossly incorrect answers may be downvoted, but I disagree with gratuitously downvoting constructive answers that are not quite perfect but are still in the right direction and help to actually get close to solving the problem - and maybe spur others on to get the exact answer. They will naturally fall lower down the page of their own accord as a result of other, better answers floating to the top.
Hey thanks for the quic reply. Yes I want to open a terminal window to execute the file, but when using your code I get this error:
|
0

@TheUnderBrony don't use do shell script but use do script. do shell script is part of the standard addition.osax which open an shell in the background do script is part of the terminal which will execute the string in a terminal window.- dj bazzie wazzie

This solved my problem, thank you! But Only one slight problem is left: The terminal starts and opens the program, but it opens it in the background, aka, I need to click on the terminal icon to show the window. Do I need to activate the window? If so, how? But already thanks a bunch :)

1 Comment

Yes, inside the tell application "Terminal" block you can add the line activate and terminal will become the frontmost application.

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.