Sorry all, the OS is Solaris 8 and the version of Perl is 5.005_03. I know, it's outdated, trust me I know this, but there is nothing I am able to do about it.
A little more about the script... Basically, it is entirely command line. You ssh into the server and then you load up the menu. There is no X session at all. It is entirely command line. Now, basically the idea is that we start with a menu and we end with a $script and $infile variable, which are then passed to another script. So we're building a command line is all the menu is really doing. However, there is a lot of input and the menu changes based on user input. Again, a little revised version here, but this is what I have thus far:
#!/usr/bin/perl
use strict;
use Menu;
my $username=getlogin();
my $infile="/tmp/$username.inFile";
my ($script,$infile=mainMenu($infile);
sub mainMenu {
my $infile=shift;
my ($choice,$notice);
while (1) {
system("clear");
print BOLD BLUE <<EOF;
PLEASE CHOOSE AN OPTION FROM BELOW
EOF
print GREEN <<EOF;
(A) Account Administration
-------------------------------
EOF
if ($notice ne "") {
print RED "\n\n$notice\n\n";
$notice="";
}
my $choice=getInput("Please enter your choice > ");
if ($choice =~ /a/i) {
accountMenu($infile);
last;
}
else {
$notice="INVALID OPTION!";
next;
}
}
}
sub accountMenu {
my $infile=shift;
my ($notice,$choice);
while (1) {
system("clear");
print BOLD BLUE <<EOF;
PLEASE CHOOSE AN OPTION FROM BELOW
EOF
print GREEN <<EOF;
(1) Add Account(s).
-------------------------------------------------
(M) Back to Main Menu.
EOF
if ($choice == 1) {
addAccount($infile);
last;
}
else {
$notice="INVALID OPTION";
next;
}
}
sub getInput {
my $message = shift;
my $return;
print "$message";
chomp($return=<STDIN>);
return $return;
}
sub addAccount {
my $infile = shift;
while (1) {
system("clear");
print BOLD BLUE <<EOF;
PLEASE CHOOSE AN OPTION FROM BELOW
EOF
print RED <<EOF;
(1) Load User File.
(2) Manually Enter Each User.
-------------------------------------------------
(A) Back to Account Administration Menu.
(M) Back to Main Menu.
(E) Exit.
EOF
if ($notice ne "") {
print RED "\n\n$notice\n\n";
$notice="";
}
my $choice=getInput("Please enter your choice > ");
if ($choice == 1) {
loadFile();
last;
}
elsif ($choice == 2) {
manuallyEnterUser();
last;
}
elsif ($choice =~ /a/i) {
accountMenu();
}
elsif ($choice =~ /m/i) {
mainMenu();
}
elsif ($choice =~ /e/i) {
exit(0);
}
else {
$notice="INVALID OPTION";
next;
}
}
}
Now, the user can then load a file, at which point they type in full path to file, and then all options are validated and if file is good then their infile gets returned as the infile, and script gets returned. If a line in user infile is not valid then they must fix the error. Anyway, this is a huge convuluted way of doing a simple task, and I just know there is an easier way of doing this. | [reply] [d/l] [select] |
#! /bin/ksh
PS3="Select an item:"
select ITEM in opt1 opt2 opt3 opt4 ; do
case "$ITEM" in
opt1) ... ;;
opt2) ... ;;
opt3) ... ;;
opt4) ... ;;
*) echo "Bad call" ;;
esac
done
A user level that continues to overstate my experience :-))
| [reply] [d/l] |