Shell script - bad interpreter: Operation not permitted

4

I put the below script in a file called "volume", and put that file in a folder within $PATH. I can execute it fine by "bash thatpath/volume 10" but when I try to execute it using just "volume 10" from anywhere I get "/bin/bash: bad interpreter: Operation not permitted". The file's permissions are 755.

#!/bin/sh

FIRST_ARGUMENT="$1"
echo "Set volume to $FIRST_ARGUMENT!"
osascript -e "set volume output volume $FIRST_ARGUMENT"

Jonny

Posted 2012-03-11T04:19:49.840

Reputation: 504

4

Is the FS mounted noexec? Is it possible the file has Windows line endings (CR+LF instead of just LF)? http://unix.stackexchange.com/questions/6821/bash-wont-execute-files

– user55325 – 2012-03-11T04:46:38.670

1I read some similar issue and they also noted that the line endings might be messed up. So I started a new file and typed that all once more and saved. +x:ed it and it started working. So I guess yes, the line endings were the culprit. I did edit the file first time with TextEdit, it shouldn't give Windows line endings but um anyway it's fixed now. – Jonny – 2012-03-11T10:09:35.057

The strings command should help you fix the issue without having to manually type the whole file again. – Reuben L. – 2012-06-12T05:52:45.170

Jonny, you should answer your own question. – MrDaniel – 2012-07-27T15:22:27.707

Answers

0

I read some similar issue and they also noted that the line endings might be messed up. So I started a new file and typed that all once more and saved. +x:ed it and it started working. So I guess yes, the line endings were the culprit. I did edit the file first time with TextEdit, it shouldn't give Windows line endings but um anyway it's fixed now.

Jonny

Posted 2012-03-11T04:19:49.840

Reputation: 504

0

For posterity, I hit this on my Mac after renaming a shell file in Finder that was open in BBEdit. Then, when I modified the file in BBEdit (which correctly reflected the new filename) and saved, I could no longer run the script.

For me, the fix was as simple as quitting BBEdit and re-launching, then saving the file once more. ‍♂️

My issue was happening regardless of whether or not arguments were included.

user2423555

Posted 2012-03-11T04:19:49.840

Reputation: 1