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.


In reply to adding a group to the Unix System by deyaneria

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.