Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Want to Create Unix group using perl script

by almut (Canon)
on Mar 17, 2010 at 14:01 UTC ( #829175=note: print w/ replies, xml ) Need Help??


in reply to Want to Create Unix group using perl script

For checking if a group exists you can use getgrnam (scalar getgrnam("foo") — returns the GID, or undef if a group of the given name doesn't exist).

For creating a new group, I'd use the respective command supplied by your system, such as groupadd (call it via system) — there's no reason to reinvent the wheel and run into various gotchas that can be avoided by using existing tools.


Comment on Re: Want to Create Unix group using perl script
Select or Download Code
Re^2: Want to Create Unix group using perl script
by JavaFan (Canon) on Mar 17, 2010 at 14:40 UTC
    It seems groupadd already does everything the OP wants: if the group doesn't exist, it adds it - if it does exist, it prints a message it already exists.

    Looks to me the OP just wants a three line shell script. Doesn't seem worth the trouble of writing a Perl wrapper for that.

Re^2: Want to Create Unix group using perl script
by abhi.nitk2003 (Initiate) on Mar 18, 2010 at 05:14 UTC
    Thanks for the help guys it worked for me.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2015-07-06 09:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls