deyaneria has asked for the wisdom of the Perl Monks concerning the following question:
Thank to the lovely monks help I have been working out my coding project for the week. However I have run into an issue regarding groups. I have been using the following code to add a group. It seems the group is not being added even though I get no errors when running the code. After I add a group I've been leaving the script and checking to see if group has been added in the terminal using the cat /etc/group command. I don't see it added. Any ideas why? I apologize for any mistakes word might have put in I can't seem to copy and paste from the shell. I am using oracle vm with Ubuntu and perl version 5.18.2 I am also using warning and strict and have no errors coming up.
3 => sub{ # do groupadd my $groupName = get_group (“Please enter new group name: “); if (getgrnam($groupName)) { print “Group already exists.”; } else { #if group does not exist create group ## FIXME delete “echo” system (“echo” , “groupadd”, “$groupName”); print “$groupName has been added. \n”; } }, sub get_group{ my $group = shift; print $group; chomp (my $ngroup = <>); return $nGroup; }
As I have to call for groups several times during the program I created a subroutine for it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: adding a group to the Unix System
by hdb (Monsignor) on Mar 15, 2015 at 17:48 UTC | |
by deyaneria (Acolyte) on Mar 15, 2015 at 17:55 UTC | |
by deyaneria (Acolyte) on Mar 15, 2015 at 18:05 UTC | |
|
Re: adding a group to the Unix System
by eyepopslikeamosquito (Archbishop) on Mar 15, 2015 at 20:56 UTC | |
by deyaneria (Acolyte) on Mar 15, 2015 at 21:25 UTC | |
|
Re: adding a group to the Unix System
by RichardK (Parson) on Mar 15, 2015 at 18:00 UTC | |
by deyaneria (Acolyte) on Mar 15, 2015 at 18:08 UTC |