my $hnlistFile = "/etc/backuppc/".basename($0).".hnlist";
my $velistFile = $ENV{HOME}."/log/".basename($0).".velist";
-# Uncomment one of the following
+# Write to the debug file only if it is already present
+my $dbgfn = "/tmp/BackupPC_ovz.debug";
my $dbgf;
-open $dbgf, ">>/tmp/BackupPC_ovz.debug" || die "Cannot open debug file";
-#open $dbgf, ">>/dev/null" || die "Cannot open debug file";
+if ( ! -f $dbgfn) {
+ $dbgfn = "/dev/null";
+}
+open $dbgf, ">>$dbgfn" || die "Cannot open debug file $dbgfn";
sub mydie($)
{
print(STDERR "Perl code fragment for exec shouldn't return!!\n");
exit(1);
} else {
- $cmd = [split(/\s+/, $cmd)] if ( ref($cmd) ne "ARRAY" );
+ $cmd = [split(/\s+/, $cmd)] if ( ref($cmd) ne "ARRAY" );
+ print $dbgf ": execing command $cmd\n";
alarm(0);
$cmd = [map { m/(.*)/ } @$cmd]; # untaint
#
$? = 0;
$cmd = join(" ", $cmd) if ( ref($cmd) eq "ARRAY" );
if ( (ref($cmd) eq "ARRAY" ? $cmd->[0] : $cmd) =~ /^\&/ ) {
+ print $dbgf ": evaluating command $cmd\n";
eval($cmd);
} else {
+ print $dbgf ": running command $cmd\n";
system($cmd);
}
}