22

I have a command that I regularly need to run in the Terminal (for application code signing). Normally I launch the Terminal, press the up arrow until I reach the command I want, and then hit enter.

I've decided that a more sustainable solution might be to create a file I can just double-click to run the Terminal command. In my searches, I discovered that I could create a text file with the .command extension which contains the command that I want to run.

However, when I double-click on this file, the Terminal opens and I get the following error:

The file “Sign Code.command” could not be executed because you do not have appropriate access privileges.

To view or change access privileges, select the file in the Finder and choose File > Get Info.

The problem is that when I go to the Get Info wind as directed and look at my Permissions, it says that my user has read-write access (the only other option is read). So in other words, I have the highest permissions, but still can't open this file.

What can I do to solve this?

34

You need to set 'execute' on the file for it to allow you to run it:

chmod u+x /path/to/file.command

u is the owner of the file, +x adds 'execute', so u+x gives the owner of the file the ability to execute it

…then you can run it in the future by double-clicking it.

  • So the error message is wrong and I can't fix the permissions by going to the Get Info window like it says? I don't have a problem with using the Terminal to fix it, I'm just surprised that the message might tell me to do something wrong. – Thunderforge Dec 15 '13 at 21:21
  • @Thunderforge Indeed, it's wrong, as far as I know :) I'm pretty sure Finder can't do it — you have to do it using Terminal or other script. – grg Dec 15 '13 at 21:23
  • +1 for explaining what u+x means. I had always wondered. – Luc Nov 9 '15 at 3:02
  • @Thunderforge Yes, it's so shocking that Apple has a useless error message... Be thankful they have one at all, and it's essentially correct even. Their m/o is to normally just have something fail with no explanation why, or that you should expect anything to happen. That's why laymen say Apple devices never have errors! – BuvinJ Nov 17 '16 at 19:19
  • You are a genius. I've been pulling my hair out for the past forever over this, completely forgetting the u part... Thank you! – Zizouz212 Jul 19 '17 at 4:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .