Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: adding a group to the Unix System

by eyepopslikeamosquito (Archbishop)
on Mar 15, 2015 at 20:56 UTC ( [id://1120117]=note: print w/replies, xml ) Need Help??


in reply to adding a group to the Unix System

Not specifically answering your question, but be aware that Perl has a number of built-in functions relating to users and groups, for example: getlogin, getpwnam, getgrent. See Perl functions for fetching user and group info.

And it is usually preferable to use the Perl builtin function rather than an external command (for why, see Unix shell versus Perl).

Though I am not aware of a Perl builtin function that can add a Unix group, you could use them to help you verify the changes you make. To illustrate, the test program below prints all groups on the system along with which users are in each group:

use strict; use warnings; my $user = getlogin(); my ($uid, $primarygid, $home, $shell) = (getpwnam($user))[2,3,7,8]; defined($uid) or die "$0: error user '$user' does not exist\n"; print "user='$user' primary gid=$primarygid\n\n"; while (my ($name, $pw, $gid, $members) = getgrent) { print "gid : $gid\n"; print "group name : $name\n"; print "members : $members\n\n"; } endgrent();

Replies are listed 'Best First'.
Re^2: adding a group to the Unix System
by deyaneria (Acolyte) on Mar 15, 2015 at 21:25 UTC
    Thanks for the link...I got the groups being added now just need to figure out how to add a new user to an existing group and a new group. I'm hoping your link might help with that.I've had 2 weeks of UNIX and 2 weeks of Perl now in the one class. It seems to be kicking my butt:) But I will plow through:)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1120117]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-23 20:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found