newbie - Output to multiple Filehandles

From: Jeremy Phillips (jeremy.phillips_at_pfizer.com)
Date: 05/24/04

  • Next message: Jürgen Exner: "Re: newbie - Output to multiple Filehandles"
    Date: 24 May 2004 08:38:50 -0700
    
    

    Hi,

    I am writing one of my first perl scripts and would like to send
    output to a logfile and stdout simultaneously. In addition, I'd like
    to be able to specify that some output only be sent to STDOUT or only
    to the logfile.

    Currently, I am using the following to print to stdout and the logfile
    simultaneously.

    open(STDOUT, "| tee -a $logFileName");

    To print only to the logfile, I create a filehandle for it in the
    usual sense

    open(LOGFILE, ">>$logFileName");

    The problem is that I have no way of specifying output to only
    standard output, leaving the logfile alone. Can anyone tell me how to
    do this? I would greatly appreciate any help.

    Thanks,

    Jeremy


  • Next message: Jürgen Exner: "Re: newbie - Output to multiple Filehandles"

    Relevant Pages

    • Re: Redirecting file handler to STDOUT (SOLVED)
      ... On 22/06/07, Paul Lalli wrote: ... > passed the stuff that goes to the log file is send to standard out ... > LOGFILE to STDOUT (i.e. make the two the same thing. ...
      (perl.beginners)
    • Re: ksh tee rm
      ... properly send output via tee. ... It currently only sends it to STDOUT ... rm file1 2>&1 | tee logfile ... But note that if stdout and stderr in the script are pointing to ...
      (comp.unix.shell)
    • Re: ksh tee rm
      ... properly send output via tee. ... It currently only sends it to STDOUT ... rm file1 2>&1 | tee logfile ... But note that if stdout and stderr in the script are pointing to ...
      (comp.unix.shell)
    • Re: Problem with logging multiple processes in Expect via trace
      ... >output to the appropriate logfile based on $expect_out. ... >commands often depend on previous successes). ... >$expect_outis only written after a successful expect match. ... >variable either in Expect or Tcl that contains STDOUT (in real time, ...
      (comp.lang.tcl)
    • Re: newbie - Output to multiple Filehandles
      ... > I am writing one of my first perl scripts and would like to send ... > output to a logfile and stdout simultaneously. ... > The problem is that I have no way of specifying output to only ...
      (comp.lang.perl)