0

I have this in a bash script which when I try to run it it gives a permission denied. I am trying to create a mac finder shortcut from one location to anther.

#!/bin/bash 
`osascript -e 'tell application "Finder" to make alias file to POSIX folder` `"/Users/tcokimac/Desktop/GSuits Setup" at POSIX folder "/Users/tcokimac/Desktop/Copy To"'`

Running it fails as follows:

tcokimac@Teens-iMac-Pro ~ % /Users/tcokimac/Documents/shell\ scripts/createproject2.sh
zsh: permission denied: /Users/tcokimac/Documents/shell scripts/createproject2.sh
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • Why do you have backticks around the line? – Charles Duffy Feb 24 '20 at 16:21
  • To be very clear, putting backticks around a line is a [*command substitution*](https://wiki-dev.bash-hackers.org/syntax/expansion/cmdsubst); it tells the shell to run its contents, but then, after doing so, put any stdout that was written by the process running those commands into a *new* command and run that as well. I don't know if your `osascript` command writes anything to stdout, but if it does, it's then running a *second* shell command after `osascript` finishes, which is almost certainly behavior you don't actually want. – Charles Duffy Feb 24 '20 at 16:22
  • Generally, instead of a line containing only `$(some-command-here)` or its backtick-based equivalent, you should just have that line contain only `some-command-here`. – Charles Duffy Feb 24 '20 at 16:23
  • See [Is it OK for users to edit the accepted answer into their question?](https://meta.stackoverflow.com/questions/262806) on [meta]. The correct way to mark your answer as solved is to accept an answer describing the solution by clicking the checkbox next to that answer (or adding your own answer and accepting it after the mandatory delay, if nobody else added a correct one). Similarly, [How to treat an old question that has an answer edited into it?](https://meta.stackoverflow.com/questions/289344]). – Charles Duffy Feb 24 '20 at 16:26

1 Answers1

1

Did you set execution permission on the script file? If not try :

chmod +x /Users/tcokimac/Documents/shell scripts/createproject2.sh
rolf82
  • 1,531
  • 1
  • 5
  • 15