V
Vahid
Hi,
I have a program that generates some output but I need it to dump them
to a file if ran in a background and print on screen if ran in
foreground. This is a sample program that need some help with:
#!/bin/perl
#
use warnings;
use strict;
#
my $today=`date +%Y%m%d`; chomp $today;
my $LOG="/tmp/output.$today.log";
my $foreground="$LOG";
if ( -t STDOUT) {
$foreground=STDOUT;
}
open (LOGfh, "> $foreground") or die "ERROR: $!";
print LOGfh "The foreground is $foreground\n";
close LOGfh;
Of course this will give me error for using STDOUT in open.
Thanks,
I have a program that generates some output but I need it to dump them
to a file if ran in a background and print on screen if ran in
foreground. This is a sample program that need some help with:
#!/bin/perl
#
use warnings;
use strict;
#
my $today=`date +%Y%m%d`; chomp $today;
my $LOG="/tmp/output.$today.log";
my $foreground="$LOG";
if ( -t STDOUT) {
$foreground=STDOUT;
}
open (LOGfh, "> $foreground") or die "ERROR: $!";
print LOGfh "The foreground is $foreground\n";
close LOGfh;
Of course this will give me error for using STDOUT in open.
Thanks,