🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
3 messages
3 total messages Started by Wm E Davidsen Jr Wed, 19 Sep 1990 13:24
error and out redirection
#1177
Author: Wm E Davidsen Jr
Date: Wed, 19 Sep 1990 13:24
41 lines
1617 bytes
  The other day I posted an example of redirecting stdout into one file,
stderr into another, and printing the error messages as they happened. I
reversed the names of the files.

  Several people have told me they can't make this work, so here's my
demo script of how to do it. It runs on SunOS, Ultrix, Stelix, Convex,
Xenix, and V5.3.2.

#!/bin/sh

# script to test redirection of stderr and stdout
#
#   Sends stdout to junk.out, stderr or junk.err AND the screen

# write the 2nd level script
cat <<XX >junk.sh
# generate output to stdout
echo "This is regular output"

# output to stderr
echo "This is a test error message" >&2
XX

# now test it ================ redirection here! ================
echo "___ Begin test. A dummy error message should appear:"
sh junk.sh 2>&1 >junk.out | tee junk.err

# comment and display files
echo; echo "___ This should be stdout"
cat junk.out
echo; echo "___ This should be stderr"
cat junk.err

# cleanup
rm -f junk.sh junk.out junk.err
# ================================================================

-- 
bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
    VMS is a text-only adventure game. If you win you can use unix.
Re: error and out redirection
#1188
Author: John T Ellis
Date: Thu, 20 Sep 1990 17:38
30 lines
1708 bytes
In article <2682@crdos1.crd.ge.COM> davidsen@crdos1.crd.ge.com (bill davidsen) writes:
>
>  The other day I posted an example of redirecting stdout into one file,
>stderr into another, and printing the error messages as they happened. I
>reversed the names of the files.
>
>  Several people have told me they can't make this work, so here's my
>demo script of how to do it. It runs on SunOS, Ultrix, Stelix, Convex,
>Xenix, and V5.3.2.
Stuff deleted
-- 
>bill davidsen	(davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
>    VMS is a text-only adventure game. If you win you can use unix.

For CSH users, you can do the following:

% (command > std.out) &> std.err

Why this works is that you FIRST execute () with the standard output going
to std.out, BUT any errors generated by () will be MERGED with standard
output to std.err.  Since you already sent standard output somewhere else,
the merge results in only the errors!  Pretty slick eh?!

Later.

-- 
---------------------------------------------------+----------------------------
Any sufficiently advanced technology               | John T. Ellis  708-632-7857
   is indistinguishable from magic.  :-}           |     Motorola Cellular
                                                   |   ...uunet!motcid!ellis
Re: error and out redirection
#1203
Author: Michael Meissner
Date: Thu, 20 Sep 1990 20:58
18 lines
1174 bytes
In article <4444@orchid12.UUCP> ellis@motcid.UUCP (John T Ellis)
writes:

| For CSH users, you can do the following:
| 
| % (command > std.out) &> std.err
| 
| Why this works is that you FIRST execute () with the standard output going
| to std.out, BUT any errors generated by () will be MERGED with standard
| output to std.err.  Since you already sent standard output somewhere else,
| the merge results in only the errors!  Pretty slick eh?!

The word pathetic comes to mind before slick.
--
Michael Meissner	email: meissner@osf.org		phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142

Do apple growers tell their kids money doesn't grow on bushes?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads