Re: Redirecting Stderr to Screen AND A File At The Same Time

From: c0ldbyte (c0ldbyte_at_comp.unix.admin)
Date: 03/31/05


Date: Thu, 31 Mar 2005 06:36:06 GMT


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2005-03-31, absinth <absinth@gmail.com> wrote:
> How do I redirect the output of my script's standard error both to the
> terminal and to a file?
>
> For example I've tried:
> ./eimScTest.ksh 2>blah.out 2>&1
>
>
> To no avail
>

First of all you need to get the tty that the message should be printed
to. For example ( echo "Hello World!" >`tty` ). notice command tty in
back quotes ``, well those are telling the whole command to process
the tty command first. Now that we have the console part taken care of
on to bigger and better things like putting it in a file at the same
time. For this to happen Im sure there are multiple ways of doing it
but number one is break it into two commands and set a variable to hold
the output of the script first and then echo $VARIABLE into the terminal
and the file.

Best of luck,
        --c0ldbyte

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)
Comment: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xF7DF979F
Comment: Fingerprint = D1DC 0AA4 1C4E EAD4 24EB 7E77 B261 50BA F7DF 979F

iD8DBQFCS5pVsmFQuvffl58RAjfaAJ922BorlkYMSrpnKL/H2+CF5MmBmACfRcqd
BHlUYw44Dg52OkX8STbXdmE=
=8TCF
-----END PGP SIGNATURE-----

-- 
( When in doubt, use brute force. -- Ken Thompson 1998 )


Relevant Pages

  • Re: [SLE] diff command and saving results to a file
    ... You don't pipe to a file, you pipe to a command. ... To redirect the output to a file you use the> operator, ... There are ways of redirecting standard error also, ...
    (SuSE)
  • Re: nohup
    ... i am not sure about this command. ... standard output or standard error - the '>outputfile' would redirect ... standard output to 'outputfile', and the '2>&1' would redirect standard ...
    (comp.unix.aix)
  • Re: Redirecting lpt1 output to an installed printer
    ... to the lpt1 port. ... I am doing now is to redirect the output using the "net use" ... If there's a recognized printer on that port, ... which I do via a "net use LPT1" command inside a batch file. ...
    (microsoft.public.vb.general.discussion)
  • Re: How to capture "legacy" program output in MSH and redirect them to MshHostUserInterface
    ... command is redirected in the script or not. ... to see if the output of the script command is the default output pipe. ... The workaround is to always explicitly redirect native ... RedirectAlways flag on the runspace that will cause legacy applications to ...
    (microsoft.public.windows.server.scripting)
  • Re: net use script issue with terminal server and DFS
    ... redirect stdout into NUL ... command will be redirected to NUL, ... But it should give you an error message when you execute the same ...
    (microsoft.public.windows.terminal_services)