chris01010
Programmer
Hi,
I'm trying to wrtie a menu perl script which will allow users to connect to different servers from a management server without having to know the long server name.
I have written the below code, but when I execute it I manage to get through the first 2 menus but it doesn't exit once connected to the server (I thought the Last command would cause the Loop to exit).
Any ideas?
#!/usr/bin/perl
do
{
system('clear');
print "Please Select a Server";
print <<MENU_END;
[1].................BOB
[2].................BERT
[3].................HARRY
[4].................LEE
[5].................BILL
[6].................ANDY
[Q].................Quit
MENU_END
chomp($choice = <>);
RESPONSE1:
{
$choice = '1' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto BOB$dc`; sleep 2; last RESPONSE1; };
$choice = '2' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto BERT$dc`; sleep 2; last RESPONSE1; };
$choice = '3' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto HARRY$dc`; sleep 2; last RESPONSE1; };
$choice = '4' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto LEE$dc`; sleep 2; last RESPONSE1; };
$choice = '5' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto BILL$dc`; sleep 2; last RESPONSE1; };
$choice = '6' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto ANDY$dc`; sleep 2; last RESPONSE1; };
};
} while $choice ne 'Q';
I'm trying to wrtie a menu perl script which will allow users to connect to different servers from a management server without having to know the long server name.
I have written the below code, but when I execute it I manage to get through the first 2 menus but it doesn't exit once connected to the server (I thought the Last command would cause the Loop to exit).
Any ideas?
#!/usr/bin/perl
do
{
system('clear');
print "Please Select a Server";
print <<MENU_END;
[1].................BOB
[2].................BERT
[3].................HARRY
[4].................LEE
[5].................BILL
[6].................ANDY
[Q].................Quit
MENU_END
chomp($choice = <>);
RESPONSE1:
{
$choice = '1' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto BOB$dc`; sleep 2; last RESPONSE1; };
$choice = '2' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto BERT$dc`; sleep 2; last RESPONSE1; };
$choice = '3' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto HARRY$dc`; sleep 2; last RESPONSE1; };
$choice = '4' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto LEE$dc`; sleep 2; last RESPONSE1; };
$choice = '5' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto BILL$dc`; sleep 2; last RESPONSE1; };
$choice = '6' && do {
system('clear');
print "Which Data Centre: ";
chomp($dc = <>);
`./goto ANDY$dc`; sleep 2; last RESPONSE1; };
};
} while $choice ne 'Q';