1

I am trying to write a script that makes our network (active directory) users local administrator on their macs. I have the script that will do this:

dseditgroup -o edit -n /Local/Default -a networkuser -t user admin

but I am looking to replace 'networkuser' with the currently logged on user, or even all users on the computer. The reason for this, is I want to push this out to multiple computers using Apple Remote Desktop, and it would save a whole bunch of time than running the script individually per user.

Does anyone know how to edit this script so it will affect the currently logged on user, or all users on the computer?

Thanks

3
  • does whoami work for you in macland? it works in most linux shells. May 9 '14 at 14:32
  • whoami (as 'who am i') will print the current user, but I don't think it will allow the script to work.
    – jasetech
    May 9 '14 at 15:36
  • as Louis mentioned, in most shells you can embed commands and other invocations within a command string by using `` quotes (the one on the tilde key for a US keyboard). for instance "echo today is date" prints "today is Fri May 9 12:56:46 EDT 2014" Edit: I surrounded teh "date" command in backticks, in the command above. SE appearently renders those a code samples, so you can't see them in my example. May 9 '14 at 16:58
1

You could try the following command:

dseditgroup -o edit -n /Local/Default -a `whoami` -t user admin

Note the backticks before and after whoami. These will run the whoami command and use the output in your command.

1
  • whoami will give the username the script is running as ("root"), not the currently logged in user. May 11 '14 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.