CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [Laurent_R] Creating Users/Groups: Edit Log

New User

Dec 9, 2012, 10:21 AM

Views: 2238
Re: [Laurent_R] Creating Users/Groups

It seems that everything works. The program complains about the break in case statement being unquoted. How can I loop this application so that after completing a task except exiting it will prompt the menu again?

#!/usr/bin/perl -w

#use strict;
use warnings;
use Switch;

print "\n Maintenance Tasks Menu \n
1 - Create UNIX Group
2 - Drop UNIX Group
3 - Create User
4 - Drop User
5 - Exit
Please enter the task number you wish execute \n" ;

my $user_input = <> ;
chomp ($user_input) ;
case 1 { print "Enter group name to create\n";
my $user_input = <>;
chomp ($user_input);
system("groupadd $user_input"); break; }
case 2 { print "Enter group name to delete\n";
my $user_input = <>;
chomp ($user_input);
system("groupdel $user_input"); break; }
case 3 { print "Enter user name to create\n";
my $user_input = <>;
chomp ($user_input);
system("useradd $user_input"); break; }
case 4 { print "Enter user name to delete\n";
my $user_input = <>;
chomp ($user_input);
system("userdel $user_input"); break; }
case 5 { print "You are now exiting the application\n";
exit; break;}

else { print "Invalid task number, please try again\n"; }

(This post was edited by stevenj0728 on Dec 9, 2012, 11:26 AM)

Edit Log:
Post edited by stevenj0728 (New User) on Dec 9, 2012, 11:26 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives