Jackp90
December 12th, 2008, 10:40 PM
This script doesn't work for some reason:
#!/usr/bin/perl
use warnings;
use strict;
# Author: Robert
# Date: 20081211
print "Would you like to shutdown your computer? ", '(y/n)';
my $answer;
$answer = <STDIN>;
if ($answer eq "y"){
print "Do you want a delay? ", '(y/n)', "\n";
my $y;
$y = <STDIN>;
if ($y eq "n"){
system "shutdown -s -t 120";
}
elsif ($y eq "y"){
print "Time delay in seconds: ";
my $time;
$time = <STDIN>;
system "shutdown -s -t $time";
}
else {
print "Please enter an appropiate value: \n";
print "Would you like a delay?", '(y/n)',"\n";
my $y;
$y = <STDIN>;
if ($y eq "n"){
system "shutdown -s -t 120";
}
elsif ($y eq "y"){
print "Time delay in seconds: ";
my $time;
$time = <STDIN>;
system "shutdown -s -t $time";
}
else {
print "Error with Standard Input \n";
}
}
}
elsif ($answer eq "n"){
print "Exiting program now \n";
}
else {
print "Error with Standard Input \n";
print "Try running the program again and answer in: 'y' or 'n'", "\n";
print "Now exiting program \n";
}
this is a school project that i was working on in Windows hence the Dos
the code for disabling a shutdown in dos is
"shutdown -a"
in case anyone gets it to work . . .
#!/usr/bin/perl
use warnings;
use strict;
# Author: Robert
# Date: 20081211
print "Would you like to shutdown your computer? ", '(y/n)';
my $answer;
$answer = <STDIN>;
if ($answer eq "y"){
print "Do you want a delay? ", '(y/n)', "\n";
my $y;
$y = <STDIN>;
if ($y eq "n"){
system "shutdown -s -t 120";
}
elsif ($y eq "y"){
print "Time delay in seconds: ";
my $time;
$time = <STDIN>;
system "shutdown -s -t $time";
}
else {
print "Please enter an appropiate value: \n";
print "Would you like a delay?", '(y/n)',"\n";
my $y;
$y = <STDIN>;
if ($y eq "n"){
system "shutdown -s -t 120";
}
elsif ($y eq "y"){
print "Time delay in seconds: ";
my $time;
$time = <STDIN>;
system "shutdown -s -t $time";
}
else {
print "Error with Standard Input \n";
}
}
}
elsif ($answer eq "n"){
print "Exiting program now \n";
}
else {
print "Error with Standard Input \n";
print "Try running the program again and answer in: 'y' or 'n'", "\n";
print "Now exiting program \n";
}
this is a school project that i was working on in Windows hence the Dos
the code for disabling a shutdown in dos is
"shutdown -a"
in case anyone gets it to work . . .