0

I am trying to execute a terminal command by just double clicking a .command file. But I am getting this error.

The file “myfile.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.

I have looked at this answer but it doesn't work: Full privileges on .command file, but it says I don't have appropriate privileges

I tried all of these:

sudo chmod u+x /path/to/myfile.command
chmod u+x /path/to/myfile.command
chmod u+x docker start sql_server_demo
sudo chmod a+x /path/to/myfile.command
chmod a+x /path/to/myfile.command
chmod a+x docker start sql_server_demo

In myfile.command I would have this:

docker start sql_server_demo

Nothing seems to be working. And when I go to Users and Groups then my current user does have Admin rights. So I really don't understand why I am getting this error. Does the myfile.command's location matter?

ls -la: -rw-r--r--@ 1 (myname) staff 68 Aug 16 11:20 myfile.command

file: myfile.command: ASCII text, with no line terminators

Paul Kruger
  • 171
  • 2
  • 3
  • 1
    Hi Paul, welcome to Ask Different. Can you add the output of these commands to your question: `ls -la /path/to/my_file.command` and `file /path/to/my_file.command` ? – jaume Aug 16 '19 at 14:01
  • @jaume I added both of those, does that help? – Paul Kruger Aug 19 '19 at 05:04
  • It looks like command `chmod u+x /path/to/myfile.command` didn't properly set the executable bit, the permission bits should read `-rwxr--r--@`, the `x` is missing. I can't say why you couldn't set the correct mode, you may want to share the directory where the file is located, that could help find an explanation. As a workaround, could you add the line `#!/bin/bash` to the top of the file, test if double-clicking the file works and report back? – jaume Aug 19 '19 at 07:12
  • @jaume I don't really know what happened but since today everything is working fine. I can double click a file and it works. I have no idea what changed though (I was about to test your last comment) – Paul Kruger Aug 20 '19 at 07:03
  • Hi Paul, great it's working. Could it be that the file is now executable (`rwx-r--r--`)? – jaume Aug 20 '19 at 08:21

0 Answers0