#!/bin/sh # # Short: list Mac OS X (NetInfo) groups to standard out # Version: 2.03, 13-08-01 # Author: Mark J Swift, msw AT blackpool.ac.uk # Long: For every (non system) user defined by NetInfo, this script # lists the following information: # user_realnamegroup_realname # If the output is redirected to a file, the script will create # a text file that can be imported into "MacintoshManager.app". # # 1. Log in as root # # 2. Copy this script into roots home directory # (/private/var/root/Documents). # # 3. Start a new shell process and change directory to roots home. # # cd ~/Documents # # 4. Set the execute flag is set on the script, type: # # chmod u+x lsgroups.sh # # 5. Execute the "lsgroupss.sh" script and and indirect output # to the text file "mmgroups.txt" with the following command: # # ~/Documents/lsgroups.sh > mmgroups.txt # for group_name in `nireport / /groups name` do group_id=`niutil -read / /groups/$group_name | grep -y "^gid: " | cut -d: -f2 | tr -d "\040"` if [ $group_id -gt 1024 ] then group_realname=`niutil -read / /groups/$group_name | grep -y "^realname: " | cut -d: -f2 | tr -d "\040"` if test -z "group_realname" then group_realname=$group_name fi for user_name in `niutil -read / /groups/$group_name | grep -y "^users: " | cut -d: -f2` do # does the user really exist? count=`nireport / /users name | grep -c -y "^$user_name"` if [ $count -ne 0 ] then user_id=`niutil -read / /users/$user_name | grep -y "^uid: " | cut -d: -f2 | tr -d "\040"` if [ $user_id -gt 1024 ] then user_realname=`niutil -read / /users/$user_name | grep -y "^realname: " | cut -d: -f2 | cut -d ' ' -f2-` echo $user_realname,$group_realname | tr "," "\011" fi fi done fi done