You are not logged in.
Pages: 1
A simple question: how to know in a bash script if an user belongs to certain group, let's say: operators?
--------------------------------
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales
-----------------------------------------------------------------
Offline
GROUPS An array variable containing the list of groups of which the current user is a member. Assignments to GROUPS have no effect and return an error status. If GROUPS is unset, it loses its special properties, even if it is subsequently reset.
It contains the group numbers, not the names.
Offline
actually, what I want is if an user is member of a group, do somethin, else, do something else
--------------------------------
Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo.
Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales
-----------------------------------------------------------------
Offline
check the /etc/group file? a little long winded but the only way i can think of doing it, and it's probably better done in perl as well
That looks like a much better way of trying to do what I was trying to do than trying to do what I was trying to do...
Offline
$ groups USERNAME
example
$ groups root
root bin daemon sys adm disk wheel log
so...
$ groups root | grep -qi wheel
$ if [ $? = 0 ]; then echo "root is a member of wheel"; else echo "root is not a member of wheel"; fi
root is a member of wheel
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
Pages: 1