Hope this isn't too complex of a script to try to make but this is what I'm trying to do.
Create a new group and add local users that aren't admin to the group.
So let's say the new group is 'cats' and 'dog' is the only admin on the machine. Let's say most machines only have one or two users but they're going to be different on each machine.
Since the name of the non-admin username(s) on each machine is a variable, I'm thinking the best way to add users to the 'cats' group is to go by Group ID but the only groups I know of are Wheel, Staff and Admin. All users on the Mac are a member of Staff by default so is there an identifier that represents a non-admin user which I can use to add them to the 'cats' group?
Hope that makes sense.
Here's what I have so far but it isn't much and I'll be honest, I can't figure from the dseditgroup man pages to do this.
Should I use dscl to append the group or continue to use dseditgroup?
If you happen to be one of those whizzo's that can just whip one of these from the hip, be prepared, I'll probably ask 'why' you decided to do something a certain way so I can learn. I'm not just looking for someone to write it out so I don't have to think.
I really have been googling all over trying to figure this out. Just seems like a little coaching from you experts would sure help.
Is this even a do-able thing? I've been trying to figure it out but bash scripting is new to me but something I'd like to learn. Seems like a very powerful way of getting a lot of repetitive tasks done.
Thanks in advance!
Stop
---------- Post updated at 09:54 PM ---------- Previous update was at 09:52 PM ----------
I guess another way would be to create the group and add all users only tell it to somehow ignore 'dog'.
Not sure if that's possible. I didn't see a way to 'ignore' users.
Also saw dsimport but that seems a bit excessive.
Thanks again,
Stop
Last edited by vbe; 01-12-2011 at 05:13 AM..
Reason: code tags please
I would suppose admins have admin rights in the sudoers file in order to use sudo as root (like you) I would look there for a start...
Compare with your account in what groups are you the other users arent? If not pertinent look at the sudoers file
After reading around and talking to a friend who's done some bash scripting. I think I'm going to have to write a 'for' loop to define the variables after creating the group.
If/when I get this figured out I'll come back and share.
/stop
---------- Post updated at 09:36 PM ---------- Previous update was at 09:33 AM ----------
Well, here's what I've got. Probably way off but what do you think? Where have I gone wrong the most?
thanks for your feedback.
/stop
Last edited by Scott; 01-14-2011 at 04:16 AM..
Reason: Code taqs, please...
if [[ $a != "Shared" ]]; then
# Excludes the dog directory
if [[ $a != "dog" ]]; then
# Excludes the DOG directory
if [[ $a != "DOG" ]]; then
Just a tip on nested if statements:
Should do the same thing (process anything other than Shared, dog or DOG), and is a little easier to look at. "||" equals "or".
There are other ways to pare down these types of statements, but I have used this construct successfully in a few scripts in the past...
In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ?
--- Post updated at 08:39 AM ---
in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
I have a script that must perform a 'sudo' operation on each of a number of hosts. I'm trying to get expect working so I only have to enter it once, and have run into a couple of issues.
First, several examples suggest to use:
/usr/bin/expect <<EOD
spawn ssh -t $host /usr/bin/sudo -v... (7 Replies)
I have a script that writes another script with
cat >/usr/local/bin/myscript.sh <<EOF
#!/bin/sh
VAR=`run a command here`
EOF
Problem is, after this is run, I get:
$ cat /usr/local/bin/myscript.sh
#!/bin/sh
VAR=result of command
How do I stop that from happening with Macs... (2 Replies)
Hi guys, I'm new here and new to shell scripting so don't be hard on me
I'm trying to create a bash script to restart a process by name in Mac OSX.
I have no problem killing the application, the problem comes when launching it again.
I managed to store the path in a variable lets say
... (8 Replies)
Hello,
I am new to Mac OSX and shell scripting all together. I was wondering if anyone could help get me started in a few scenarios so that I would be able to automate checking a system against a STIG checklist. A STIG Checklist is a DoD Guideline for securing systems. Here is the first... (3 Replies)
Hello,
On Mac OSX, I was wondering about my Cron Script:
HELL=/bin/tcsh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/var/log
MAILTO=jwillis
25 1 * * * root /Users/jwillis/Fbcmd\Scripts/DailyBirthday.scrmy returned message is:
Subject: Cron... (3 Replies)
i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine.
then last week i wrote capture.sh and it... (2 Replies)
hi,
i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Hi,
I have installed bash 3.2 via darwin ports, however when I try and change the shell i.e. chsh -s /opt/local/bin/bash is says its a non-standard shell? but if i run ./bash i get a new bash prompt with version 3.2?
Thanks (3 Replies)