How do I run a script with admin rights using OS X
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to install ecg-kit on OS X el captain and I have to run a script called 'InstallECGKit.m'with admin/root privileges. I've just bought a Mac and a little unfamiliar with OS. For the life of me, I can't figure out how to do this simple thing.
I will be very helpful for any guidance!
Thanks!
1 commentaire
Walter Roberson
le 2 Mar 2016
This is tricky to do. Normally you would go to a Terminal window and use "sudo" to start the binary you want to run with elevated privileges. However, if you try to do that with MATLAB, it will complain that your userid does not match the entry in the license file.
I found a utility somewhere named LaunchAsRoot and I am able to start MATLAB from that, but I am not certain that I get admin privileges this way; the evidence I saw suggested not.
Réponses (1)
Jan
le 2 Mar 2016
Can you gain admin privileges to the current user?
1 commentaire
Walter Roberson
le 2 Mar 2016
Not easily, not in OS-X or Linux. Although there are secure Linux systems where individual access rights can be allocated to a non-root user, the traditional form of access privileges is to change the effective userid to 0 (root) -- and if you do that then MATLAB says "Oh, your email address does not match".
If the script just needs to write some regular files or directories into a place the user would not normally have access to, then the easiest mechanism is to give the user access. That can be done by temporarily changing permissions to allow "other" to access, or in OS-X can be done by using chmod to add ACL (Access Control List).
But if the script needs to reconfigure the kernel, then you have a problem.
Depending how the script is written, it might be easiest to change the script so that each time it needs to do something privileged, it uses system('sudo ...') -- because sudo remembers user authentication for a period of time so that the first password prompt to the user would typically be sufficient to allow everything to finish.
Voir également
Catégories
En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!