#!/usr/local/bin/perl # This tests the recovery system $recovery_file = check_for_recovery_file(); # execute the script at either the recovery step or the beginning $recovery_file ? recover($recovery_file) : recover(); sub recover { my $file_name = shift; my $cmd_line = 'recover.pl'; if ($file_name) { open INFILE, "$file_name"; # assumes the recovery file contains # no more than one line of text chomp($cmd_line = ); print STDERR "Resuming failed process: '$cmd_line'"; } `$cmd_line`; die "Could not execute $file_name: $!" if ($?); print STDERR "'$cmd_line' successful\n"; } sub check_for_recovery_file { # won't hard-code this in real life $_ = 'start.rec'; (-s) ? return $_ : return 0 }