reboots the machine multiple times at the start up
I have to say that this sounds like a terrible idea. Please explain why you think that this is desirable because it looks very much like an XY Problem.
| [reply] |
What operating system does the machine have?
| [reply] |
There are various ways to automatically start a script on ubuntu. See http://askubuntu.com/questions/814/how-to-run-scripts-on-start-up
This script will be restarted each time, so you have to leave information about what to do next on your system.
Like writing to a file before rebooting and reading the status after restart.
If availability matters you'll need another machine monitoring the process.
BTW: Plz do not repost your question again!
| [reply] |
| [reply] |
Once the system reboots, the script is no longer running. You have to leave some kind of persistent information for the system to iterate the next step, probably create a file somewhere. You also have to configure the system to check for the information upon start-up.
| [reply] |
Rebooting the machine WILL stop your running script. You'll have to set things up so that the script gets restarted on the next reboot.
| [reply] |
Hi monks, am a newbee to perl, i have gone nuts trying to solve this, i want to Create a folder/file, auto reboot the machine and check for the created file/folder on the location. creating files and folders is a stuff to deal with but the second part rebooting and checking for the given file location is a tricky part. Please help me with this.Thank you.
| [reply] |
| [reply] |
Welcome. You say you've had trouble but you don't say what has gone wrong. What have you tried, how did it fail? If you are new to Perl I suggest you take the time to work through the basics:
Reporting specific problems will likely result in better answers than you'll get from simply posting the requirements you have to fulfill.
| [reply] |
Best thing i know to do would be to program how many times you want it to reboot, then write the reboot attempt number to a file on the boot partition.
psuedocode
use warnings;
use strict;
open $my file, '<', "C:/reboot_attempts";
read $file, my $reboot_number, 1;
if ($reboot_number == 0){
open my $file, '>', 'reboot_attempts';
print $file '1';
close $file;
#reboot machine;
}
if ($reboot_number == 1){
open my $file, '>', 'reboot_attempts';
print $file '2';
close $file;
#reboot machine;
}
if ($reboot_number == 2){
open my $file, '>', 'reboot_attempts';
print $file '3';
close $file;
#reboot machine;
}
if ($reboot_number == 3){
open my $file, '>', 'reboot_attempts';
print $file '4';
close $file;
#reboot machine;
}
if ($reboot_number == 4){
open my $file, '>', 'reboot_attempts';
print $file '5';
close $file;
#reboot machine;
}
if ($reboot_number == 5){
open my $file, '>', 'reboot_attempts';
print $file '0';
#exit;
}
I am sure this can be improved greatly, but if you put in there the reboot code, it should be ok. The key is to set this up as a task that will run on boot. so you may need to use a batch file to run the script, or even make the script into an exe. Otherwise i am unsure on how you would actually execute the code on boot | [reply] [d/l] |
use warnings;
use strict;
my $max_attempts = 5;
# for windows, replace cat with type
my $reboot_number = `cat reboot_attempts` || 0;
if ($reboot_number++ < $max_attempts) {
`echo $reboot_number > reboot_attempts`;
print "Rebooting...\n";
# code to make computer reboot here
}
| [reply] [d/l] |