SUMMARY: redirecting stdout and stderr in a script

From: Dan O'Callaghan (OcallD_at_cogent-dsn.com)
Date: 07/28/04

  • Next message: André Claude Benin: "Multipathing"
    Date: Wed, 28 Jul 2004 10:00:55 +0100
    To: <sunmanagers@sunmanagers.org>
    
    

    Thanks to all who replied,
    It seems that there are a couple of ways to do this,
    Ive listed the methods used by Karl Vogel

    Two ways to do it just once:

       a. Have a smaller driver script call the script that's doing all the
           work, redirecting the output as you have above.

       b. Use a subshell in your script like so:

           #!/bin/sh
           # set the PATH, do your sanity checks, etc.
           ...

           # real work starts here
           (
               command ...

               if test something; then
                   command ...
               else
                   some other command ...
               fi

               ...

           ) 2>&1 | tee logfile

    Thanks
    For the help
    Dan.

    -----Original Message-----
    From: Dan O'Callaghan
    Sent: Tuesday, July 27, 2004 3:31 PM
    To: 'Sunmanagers LIST (sunmanagers@sunmanagers.org)'
    Subject: redirecting stdout and stderr in a script

    Hi
    Ive written a script that basically extracts tar files, copies files and
    installs software.

    I want to capture the output of stdout and stderr to a log file as well as
    viewing it on screen.

    Ive worked out that I can use any_command 2>&1 | tee log.file .

    Is there anyway that I can do this once globally for the script or do I have
    to set it at the end of every command?

    Thanks in advance
    Dan.

    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.716 / Virus Database: 472 - Release Date: 7/5/2004
    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.716 / Virus Database: 472 - Release Date: 7/5/2004
    _______________________________________________
    sunmanagers mailing list
    sunmanagers@sunmanagers.org
    http://www.sunmanagers.org/mailman/listinfo/sunmanagers
    

  • Next message: André Claude Benin: "Multipathing"

    Relevant Pages

    • Re: Post from 2003-11-07 20:18 contains virus in attached file.
      ... There was no payload in the script. ... Ham just wants to perform a clean registery ... |> | Outgoing mail is certified Virus Free. ...
      (microsoft.public.security.virus)
    • Re: Help on script
      ... > Try this I would email the script to you, but being you dont know me you ... >> but the drives are mapped up. ... > Outgoing mail is certified Virus Free. ...
      (microsoft.public.windows.server.sbs)
    • RES: telnet.pm
      ... I have too much to do in my script.. ... Incoming mail is certified Virus Free. ... Checked by AVG anti-virus system. ...
      (perl.beginners)
    • Re: ROM Drive problems
      ... Doug Knox and Kelly deserve the credit for that script to be so readily ... > I was preparing to reinstall Windows. ... >>> Installation of game ... Checked by AVG anti-virus system. ...
      (microsoft.public.windowsxp.general)
    • Re: changing NT passwords across the Internet using SSL
      ... the password, but you still need a script, probably an ADSI script, to ... search www.google.com or www.microsoft.com/support for "ADSI ... Outgoing mail is certified Virus Free. ...
      (microsoft.public.inetserver.iis.security)