#! /usr/local/bin/perl –w #Author: # $choice = 0; Do{ Print “Admin Menu \n”; Print “To add a user, press 1 \n”; Print “To delete a user, press 2 \n”; Print “To Add a group, press 3 \n”; Print “To delete a group, press 4 \n”; Print “to exit this menu, press 5 \n”; Print “Please chose an option:” $choice =<>; chomp $choice; Print “You chose option: “; Print $choice; Print “\n”; } while $choice < 1 || $choice > 5; If ($choice == 1); { Do { nUsername = <>; Print “what is new users name?”; #get new user name Chomp $nUsername; #check that new user name is a string If $nUsername =~ tr/A-Za-z0-9//c; { #check to see if user exists if(getpwnam('$nUsername')) print "User exists\n"; } Else { $adduser = '/usr/sbin/adduser'; $cmd = qq($adduser --home $home --gecos $nUsername); #get new user password Do { Print “Please add password: \n”; $nPassword = <>; Print “Please re-enter password: \n”; $nPasstest =<>; } While $nPassword !eq $nPasstest; Print “Please enter group for user: \n”; nGroup= <>; #add user to group if getgrnam($group) { #check to see is group exists print $group; Print “already exists \n”; #add user to group Groupadd $nGroup; } Else {#if group does not exist create group groupadd $nGroup; Print $nGroup; Print “ has been added.\n”; } Else { Print “New username must be a string.”; $nUsername = \n; } while $nUsername = \n;