W
Whitey Johnson
I have a small backup script that tars up a dir and puts it on a different
drive. I want to get the output of tar (the list of files being tarred)
into a file. I can do it by assigning STDOUT to a file like so:
open STDOUT, ">> $logfile" or die "Can't open the log file: $!\n";
system "tar", "cvzf", $bkfile, $dir;
Question: How do I return STDOUT back to the screen after the backup has
run so I can print a message to the screen?
I have tried selecting a file like this:
open LOGFILE, ">> $logfile" or die "Can't open the log file: $!\n";
select LOGFILE;
system "tar" yada yada..
but the output goes to the screen not the file.
I have also tried a whole different method like this:
open LOGFILE, ">> $logfile" or die "Can't open the log file: $!\n";
open TAR, "tar -cvzf $bkfile $dir" or die "Tar failed: $!\n";
print LOGFILE while (<TAR>);
but the I get an error that the directory doesn't exist.
TIA
drive. I want to get the output of tar (the list of files being tarred)
into a file. I can do it by assigning STDOUT to a file like so:
open STDOUT, ">> $logfile" or die "Can't open the log file: $!\n";
system "tar", "cvzf", $bkfile, $dir;
Question: How do I return STDOUT back to the screen after the backup has
run so I can print a message to the screen?
I have tried selecting a file like this:
open LOGFILE, ">> $logfile" or die "Can't open the log file: $!\n";
select LOGFILE;
system "tar" yada yada..
but the output goes to the screen not the file.
I have also tried a whole different method like this:
open LOGFILE, ">> $logfile" or die "Can't open the log file: $!\n";
open TAR, "tar -cvzf $bkfile $dir" or die "Tar failed: $!\n";
print LOGFILE while (<TAR>);
but the I get an error that the directory doesn't exist.
TIA