Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
- The problem statement, all variables and given/known data:
I'm able to create a group but when I'm trying to delete the group it keeps stating Group Doesn't Exist. I know the group exist since I created it and look at the etc/group file which is there but for some odd reason I'm unable to delete it???
- Relevant commands, code, scripts, algorithms:
#!/usr/bin/perl
use strict;
use warnings;
my $group_name = <STDIN>;
my $group_id = <STDIN>;
my $user_name = <STDIN>;
my $user_id = <STDIN>;
my $choice = <STDIN>;
print "* My menu *\n";
print "* *\n";
print "* 1. Create a Unix Group *\n";
print "* 2. Delete a Unix Group *\n";
print "* 3. Create a Unix User *\n";
print "* 4. Delete a Unix USer *\n";
print "* 5. Quit *\n";
print "* *\n";
print "******************************************************\n";
print "* Enter Your Choice >\n";
$choice = <STDIN> ;
chomp $choice;
if ($choice == 1) {
print "**********************************\n";
print " Create A Unix Group\n";
print "**********************************\n";
print " Enter The Group Name to Create >\n";
chomp ($group_name = <STDIN>);
print " Enter the Group ID to Create >\n";
chomp ($group_id = <STDIN> );
if ( ! `grep -i $group_name /etc/group` ) {
system ("/usr/sbin/groupadd $group_id $group_name");
print "Group Created Successfully!\n"
} else {
print "Group Already Exists !\n";
}
}
elsif ($choice == 2) {
print "**********************************\n";
print " Delete a Unix Group\n";
print "**********************************\n";
print " Enter a Group Name to Delete >\n";
chomp ($group_name = <STDIN>);
print " Enter a Group ID to Delete >\n";
chomp ($group_id = <STDIN> );
if ( ! `grep -i $group_name /etc/group` ) {
system ("/usr/sbin/groupdel -g $group_id $group_name");
print "Delete Group Successfully!\n"
} else {
print "Group Doesn't Exist !\n";
}
}
chomp $choice;
if ($choice == 3) {
print "**********************************\n";
print " Create a Unix User\n";
print "**********************************\n";
print " Enter User Name You Want to Create >\n";
chomp ($user_name = <STDIN>);
print " Enter the User ID >\n";
chomp ($user_id = <STDIN>);
if ( ! `grep -i $user_name /etc/passwd` ) {
system ("/usr/sbin/useradd -m $user_id $user_name");
print "Added User Successfully!\n"
} else {
print "User Doesn't Exist !\n";
}
}
- The attempts at a solution (include all code and scripts):
Tried to get some advice from stack exchange guys but no luck. I tried changing variables but that didn't help.
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
CTU Online, N Chestnut St, Colorado Springs, CO 80907, Instructor Tarik Illes Course CS345
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).