Join Date: Sep 2000
Last Activity: 24 August 2019, 3:12 AM EDT
Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Thanks Given: 1,985
Thanked 2,642 Times in 1,457 Posts
Some of my issue was how to go about running from the admin account. The account I am in is already administrator , but I get permission denied when I try to run shutdown from a script. To authorize shutdown, I can run the script as, sudo scriptname , or I can su and then call the script.The default root account is disabled on many Mac installations, so you are not supposed to be able to change the user to root without activating the root account first. Please let me know if I am not correct about any of this.
...then I am into a terminal window and if I need a cron file to run (for example) with superuser privs, I install a root crontab. I don't create a "Neo" crontab and then write a bunch of "goofy" (sorry, but that's the first word that comes to mind, it is not directed at you or your work) sudo wrappers around a "Neo crontab script" to force the "Neo" account do accomplish what I can easily do running the script as root in the root account.
As a side note, I think it was also you who, in a earlier post (LMHmedchem, but I might be mistaken as I've busy coding sorry and don't have time to go back and review your older posts, my bad) , was working "as an exercise" to figure out how to close the MacOS terminal window in a script when the shell exits, and I read (in reply to that post) a lot of people replying to help you "in your exercise" which was confusing to me because this is simply a " 10 second preferences" selection in the MacOS terminal config dialog box.
You seemingly are asking questions, "as exercises" to solve problems that do not exist and that's OK "as exercises" and I encourage you to do so in these forums and I encourage everyone to reply who has time to reply; but honestly, you seem to have the luxury of an abundance of free time on your hands if you need to create problems in order to solve them. That's OK too. However, let me be clear since you asked me:
I write a lot of small task-related scripts on MacOS and I work in a quite robust development environment on the Mac and my "main development box" is a 12 core Mac Pro, and if I need to run a script to do "root things", like a crontab script which needs root privs , I run this script as root, configured as the root user from the root account. Boom. Task done. Move on to the next task. I never run scripts as "Neo" wrapped in a lot of "sudo" code to accomplish tasks as the superuser which I can do as the root user directly. Sorry, but why would I waste my time doing that? I have a lot to do and never enough time to do it and if I worked 12 hours a day everyday, I would still not have enough time to so all the things I need to get done in development, so I need to get things done quickly and not turn 30 second tasks into days of exploring MacOS. Hey, that's just me and more power to you if you have a lot of free time to do these "turn a one minute routine task into days of Q&A" experience.
The same is true for the earlier post about "how to close a MacOS terminal window when the shell exits"... I have shells exiting in MacOS terminal windows all the time, and if I wanted or needed those terminal windows to close when the shell exits, I would configure the terminal preference to "close window on shell exit..."
MacOS is great and I would not develop code on any other platform. If you or anyone has the luxury of a lot of time to play around with MacOS and do things in a more "difficult" way than the "10 second routine way" then by all means, go for it; but for me (and you asked me directly), when I read your posts my "inner thoughts" are "wow, this guy has a lot more free time than I do because he spends days on tasks which I can do one minute" and you seem to enjoy it; so go for it!
I used to have free time like that many years ago. I'm kinda envious to be honest