Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

people logged in based on group

Status
Not open for further replies.

afiore

IS-IT--Management
Jun 24, 2003
1
0
0
US
Hello,

Does anyone know what string might be used to determine how many people are logged onto an AIX system where a group ID begins with a given number lets say 4.

In other words, I am looking to query the system for the number of people currently logged onto a system that belong to any group starting with 4. Could be 400, 4102, 444, etc.

Thank you

Andy
 
You can try to use this shell script:

#----------------------------------------------------------
echo "Initial number GroupID: \c "
read initnumber
echo "Currently user logged that belong to groupid starting with $initnumber:"
who | awk '{print $1}' | sort | uniq | while read onlineuser
do
usergroup=`lsuser -ca pgrp $onlineuser | grep -v "#" | awk -F":" '{print $2}'`
lsgroup -c -a id $usergroup | awk -v number="$initnumber" -v user=$onlineuser -F":" 'substr($2,0,1)==number {printf "User: %s --- Groupid: %s \n",user,$2}'
done
#----------------------------------------------------------
Bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top