|
Prev: Question about wwwboard perfuctory
Next: FAQ 2.1 What machines support perl? Where do I get it?
From: xhoster on 23 Apr 2008 17:39 Vahid Moghaddasi <moghaddasi(a)gmail.com> wrote: > > > > Maybe I'm missing something, but I think this does it: > > > > unless ( -t STDOUT) { > > my $today=`date +%Y%m%d`; chomp $today; > > open STDOUT, ">/tmp/output.$today.log" or die $!; > > > > }; > > > > print "The foreground is $foreground\n"; > > > > Xho > > > Yes that does the trick, thank you. > I don't understand how does the output of the last print statement > goes to STDOUT if the program is running in the background? Sorry, I don't understand the question. Maybe you are confusing STDOUT with the terminal. Often STDOUT is hooked up to the terminal, but sometimes it is not. The concept of "background" is somewhat fuzzy. In Linux, if you start a program "in the background" by adding a &, that doesn't change the STDOUT of the program. For example, the below prints "1" because the program's STDOUT is still the terminal, despite being run in the background. perl -le 'sleep 3; print -t STDOUT' & Where as this doesn't print "1", because it's STDOUT is not the terminal, even though it is running in the foreground; perl -le 'warn -t STDOUT' > /dev/null Xho -- -------------------- http://NewsReader.Com/ -------------------- The costs of publication of this article were defrayed in part by the payment of page charges. This article must therefore be hereby marked advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate this fact.
First
|
Prev
|
Pages: 1 2 Prev: Question about wwwboard perfuctory Next: FAQ 2.1 What machines support perl? Where do I get it? |