JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
I have Applescript which executes bash shell script using administrator privileges.
Script example:
do shell script "/users/user/documents/install.sh" with administrator privileges
In Catalina, i always get an
execution error - operation not permitted (126)
message - bash script is not executed. Even if bash script is empty, error is the same, so i assume bash script is not the problem. Tried to do it as root - no success.
If i remove
with administrator privileges,
script is executed, but that's not a solution because i need to run it with privileges.
In previous macOS versions the same script is working without problems
.
Any ideas? Thx in advance!!!
Hm, i have bash here and it executes"install.sh" script perfectly in terminal (without Applescript)
sudo ./install.sh
Running applescript using
osascript
command in terminal, results in the same error.
[doublepost=1568403803][/doublepost]Nevertheless, if i use zsh, script result is following (terminal, using osascript)
Mac Documents % osascript install.applescript
install.applescript:0:97: execution error: /bin/zsh: can't open input file: /Users/user/Documents/install.sh (127)
Needless to say that script install.sh is present and accessable in documents folder.
Try do shell script "bash /users/user/documents/install.sh" with administrator privileges
Catalina has some weird permissions bugs.
Try do shell script "bash /users/user/documents/install.sh" with administrator privileges
Catalina has some weird permissions bugs.
Thx for help!
I tried this already with no success. No matter what i do, if i use "administrator privileges", script fails. There is something which blocks applescript from executing script in admin mode.
No matter what i do, if i use "administrator privileges", script fails.
One more thing chmod +x /Users/user/Documents/install.sh
Incorrect. Bash is still included with Catalina, but is no longer the default shell when you launch terminal, ZSH is. You can still call bash scripts by using #!/bin/bash at the top of your script.
As far as the OP's script not running, it likely has to do with macOS privacy controls. I don't have a Catalina machine in front of me, but check Security & Privacy for any thing about Automation.
[doublepost=1568490502][/doublepost]
zabukowski said:
Hm, i have bash here and it executes"install.sh" script perfectly in terminal (without Applescript)
sudo ./install.sh
Running applescript using
osascript
command in terminal, results in the same error.
[doublepost=1568403803][/doublepost]Nevertheless, if i use zsh, script result is following (terminal, using osascript)
Mac Documents % osascript install.applescript
install.applescript:0:97: execution error: /bin/zsh: can't open input file: /Users/user/Documents/install.sh (127)
Needless to say that script install.sh is present and accessable in documents folder.
Check and make sure "Terminal" has Full Disk Access in Privacy tab of Security & Privacy. That may fix your problem.
As far as the OP's script not running, it likely has to do with macOS privacy controls. I don't have a Catalina machine in front of me, but check Security & Privacy for any thing about Automation.
[doublepost=1568490502][/doublepost]
Check and make sure "Terminal" has Full Disk Access in Privacy tab of Security & Privacy. That may fix your problem.
I already have set Full Disk Access for Terminal. Privacy Automation settings window is empty, not sure what can i do with it.
Thx!!!
[doublepost=1568495780][/doublepost]
bogdanw said:
One more thing chmod +x /Users/user/Documents/install.sh
Attributes of the bash script are correct, because script is executed properly as standalone (sudo ./install.sh). Seems that the problem is with Applescipt not being able to execute bash script with admin privileges.
I even signed bash script, still no success. It doesn't work in root mode either. It feels like permissions issue, but I still wonder if this is actually Catalina beta bug ... not sure how to check if it's maybe already reported.
Seems that the problem is with Applescipt not being able to execute bash script with admin privileges.
I wouldn't say that, my
beta enrollment script
works in Catalina beta 8.
I've tried to run
disable.sh
form AppleScript and I got an error "/bin/sh: /Users/admin/Documents/disable.sh: Permission denied" number 126
But it run after adding bash or after chmod +x. Full disk access was not required.
I wouldn't say that, my
beta enrollment script
works in Catalina beta 8.
I've tried to run
disable.sh
form AppleScript and I got an error "/bin/sh: /Users/admin/Documents/disable.sh: Permission denied" number 126
But it run after adding bash or after chmod +x. Full disk access was not required.
Unfortunately, these suggestions are not working for me (i have beta 7, though). My bash script has execution permisson set (chmod +x) - otherwise it wouldn't run as standalone as well. Anyway, i tried to set it few times, just in case
I don't have your issue, but a different one. An Applescript I have that sets calendar alerts depending on various bits of into in the event was working fine in Mojave, but is failing now. My Feedback says "more than 10" people have reported the same issue, so there does seem to be at least one issue with Applescript in Catalina.
You are right, it doesn't work in beta 7. I get the same 126 and 127 errors. You'll just have to update
Ah, that's good news - thanks !!!
Unfortunately, the problem on beta 8 remains the same.
The problem narrows down to
applescript not being able to execute shell script with admin privileges (operation not permitted, can't open input file etc.)
regardless of shell type (bash, zsh etc.).
I think I finally understood the problem: the script tries to run in /, so permission is actually denied to the root directory.
Disable SIP, mount system as writable "sudo mount -wu /" and try the script again.
I think I finally understood the problem: the script tries to run in /, so permission is actually denied to the root directory.
Disable SIP, mount system as writable "sudo mount -wu /" and try the script again.
Hm, interesting ... but isn't disabling SIP just because of ordinary applescript a bit overkill !? Maybe there is a way to change script startup directory? How did you came to conclusion that script tries to run in / ??
Hm, interesting ... but isn't disabling SIP just because of ordinary applescript a bit overkill !? Maybe there is a way to change script startup directory? How did you came to conclusion that script tries to run in / ??
It's a temporary solution, until Apple fixes the problem.
I came to this conclusion by running
adblock_hosts.sh
from AppleScript, the temporary files are created in /
I've tried without succes with something like
do shell script "cd /users/user/documents/;" & "install.sh;" with administrator privileges
do shell script "cd /users/user/documents/;" & "sudo ./install.sh;" with administrator privileges
do shell script "cd /users/user/documents/;" & "sudo -s;" & "./install.sh;" with administrator privileges
I get Operation not permitted" number 126
Interestingly, do shell script "sudo -s" with administrator privileges doesn't get an error.
This might work
do shell script
"sudo -s"
with
administrator privileges
do shell script
"cd /users/user/documents/;" & "./install.sh;"
Unfortunately, 2nd line is executed, but NOT in privileged mode. If you append "with administrator privileges" to it, it fails as usual.
So you are sure, this is a bug in Catalina beta (i really hope so) and not something Apple just silently deprecated??
So you are sure, this is a bug in Catalina beta (i really hope so) and not something Apple just silently deprecated??
I think it's a bug. You can try something else
tell application "Terminal"
activate
do script with command ("/users/user/documents/install.sh")
end tell
By the way, why do you need to run install.sh from AppleScript and do you run it every day?
tell application "Terminal"
activate
do script with command ("/users/user/documents/install.sh")
end tell
By the way, why do you need to run install.sh from AppleScript and do you run it every day?
Applescript "do shell script with admin privileges" is a very simple way to perform user authorization and execute privileged script.
"install.sh" is basically an installer, which copies misc files all around the system, so it must have admin privileges.
Content of the install script is dynamically created. Applescript is fixed and it is called from the main app.
I know there are probably other ways to acomplish it, but this was always working as expected (tested from 10.9 to 10.14), now in Catalina is broken.
MacRumors attracts a broad audience of both consumers and professionals interested in the latest technologies and products. We also boast an active community focused on purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.
Our Staff
Editorial Director
Editor in Chief
Managing Editor
Senior Reporter
Deals Editor
Senior Editor
Senior Editor
Project Manager
Video Content Producer
Graphic Designer
Contributing Writer