[comp.unix.wizards] a.out 1> file.out 2> file.err in csh?

kmont@hpindda.HP.COM (Kevin Montgomery) (10/25/88)

Hate to be this cluelessly stupid, but something's been bugging the
hell out of me- how do you do the Bourne :

	a.out 1> file.stdout 2> file.stderr

in the csh?  ("a.out > file.stdout >& file.stderr" doesn't cut it,
since ">&" is defined to be BOTH stdout and stderr, hence is an
ambiguous redirection)

				adv -thanks- ance,
				  kevin, normally not so clueless

ps: if anyone sez 'sh "a.out 1> file.stdout 2> file.stderr"', they
    will be shot.
pps: no, I don't like bourne, so stop flaming.
ppps: yes, I can write a "Y" program easily to do it, but it should be
      possible in the csh already.

kmont@hpindda.HP.COM (Kevin Montgomery) (10/26/88)

thanks to everyone that responded: "(a.out > file.out) >& file.err" it is...

					kevin

dempsey@handel.colostate.edu. (Steve Dempsey) (10/26/88)

In article <4470006@hpindda.HP.COM> kmont@hpindda.HP.COM (Kevin Montgomery) writes:
>
>Hate to be this cluelessly stupid, but something's been bugging the
>hell out of me- how do you do the Bourne :
>
>	a.out 1> file.stdout 2> file.stderr
>
>in the csh?  ("a.out > file.stdout >& file.stderr" doesn't cut it,
>since ">&" is defined to be BOTH stdout and stderr, hence is an
>ambiguous redirection)
>				adv -thanks- ance,
>				  kevin, normally not so clueless

This is far from obvious, so no need to feel cluelessly stupid:

     ( a.out > file.stdout ) >& file.stderr


 /\             \Steve Dempsey,  Center For   \steved@longs.LANCE.ColoState.Edu
 \/ _|/ _       _\Computer Assisted Engineering\dempsey@handel.CS.ColoState.Edu
 /\  | (_) | |_(_)\Colorado State University    \...!ncar!handel!dempsey
/_/_/(_/\_/ V   \_ \Fort Collins, CO  80523      \(303)-491-0630

matthew@sunpix.UUCP ( Sun NCAA) (10/26/88)

> Hate to be this cluelessly stupid, but something's been bugging the
> hell out of me- how do you do the Bourne :
> 
> 	a.out 1> file.stdout 2> file.stderr
> 
> in the csh?  ("a.out > file.stdout >& file.stderr" doesn't cut it,
> since ">&" is defined to be BOTH stdout and stderr, hence is an
> ambiguous redirection)
> 

Check out this little clipping from my online man page.

     The only way to direct  the  standard  output  and  standard
     error separately is by invoking a subshell, as follows:

          tutorial% (command > outfile) >& errorfile

     Although robust enough for general use, adventures into  the
     esoteric  periphery  of  the  C-Shell  may reveal unexpected
     quirks.




-- 
Matthew Lee Stier     (919) 469-8300|
Sun Microsystems ---  RTP, NC  27560|          "Wisconsin   Escapee"
uucp: {sun, rti}!sunpix!matthew     |

asa@unisoft.UUCP (Asa Romberger) (10/26/88)

In article <4470006@hpindda.HP.COM> kmont@hpindda.HP.COM (Kevin Montgomery) writes:
>
>hell out of me- how do you do the Bourne :
>
>	a.out 1> file.stdout 2> file.stderr
>
>in the csh?

	(a.out > file.stdout) >& file.stderr

I have found no other way! The ambiguity is eliminated because it is separate
shells.

lew@gsg.UUCP (Paul Lew) (10/27/88)

how about:

	$ ( a.out > file.out ) >& file.err

Since csh |& and >& will put stdout and stderr together, the stdout from
subshell ( a.out > file.out ) will be empty and stderr will be redirected
to file.err.
-- 
Paul Lew			{oliveb,harvard,decvax}!gsg!lew	(UUCP)
General Systems Group, 5 Manor Parkway, Salem, NH 03079	(603) 893-1000

maart@cs.vu.nl (Maarten Litmaath) (10/27/88)

(a.out > file.out) >& file.err		# Grrrrrr!
-- 
George Bush:                          |Maarten Litmaath @ VU Amsterdam:
             Capt. Slip of the Tongue |maart@cs.vu.nl, mcvax!botter!maart

kamlesh@hpdstma.HP.COM (Kamlesh Gandhi) (10/27/88)

You might want to use the following under csh:
	 % (a.out > file.out) >& file.error
This will send your output to file.out and your errors to file.error

Kamlesh

joe@cit-vax.Caltech.Edu (Joe Beckenbach) (10/27/88)

In his article kmont@hpindda.HP.COM (Kevin Montgomery) writes:
>>Hate to be this cluelessly stupid, but something's been bugging the
>>hell out of me- how do you do the Bourne :
>>
>>	a.out 1> file.stdout 2> file.stderr
>>
>>in the csh?  ("a.out > file.stdout >& file.stderr" doesn't cut it,
>>since ">&" is defined to be BOTH stdout and stderr, hence is an
>>ambiguous redirection)

In his article dempsey@handel.colostate.edu..UUCP (Steve Dempsey) writes:
>This is far from obvious, so no need to feel cluelessly stupid:
>
>     ( a.out > file.stdout ) >& file.stderr

	I tried the most natural thing in the world: following the 'law of
least astonishment'. I did
	a.out >&file.stderr >file.stdout
and of course the rest is ambiguity. :-)

	Do any shells out there (besides sh) handle redirecting stderr
INDEPENDENT of stdout? I think that csh was very naughty in mixing the
streams-- do we have to try writing a public-domain shell in order to have
a well-distributed sane shell? [ gsh! ;-) :-) have you beat me to the punch,
FSF?]
-- 
Joe Beckenbach	joe@csvax.caltech.edu	Caltech 256-80, Pasadena CA 91125
	... or have I not seen enough code yet to throw stones? 1/2 :-)

rar@nascom.UUCP (Alan Ramacher) (10/28/88)

In article <4470006@hpindda.HP.COM>, kmont@hpindda.HP.COM (Kevin Montgomery) writes:
> 
> Hate to be this cluelessly stupid, but something's been bugging the
> hell out of me- how do you do the Bourne :
> 
> 	a.out 1> file.stdout 2> file.stderr
> 
	(a.out > file.stdout) >& file.stderr

> in the csh?  ("a.out > file.stdout >& file.stderr" doesn't cut it,

> since ">&" is defined to be BOTH stdout and stderr, hence is an
> ambiguous redirection)
> 

khb%chiba@Sun.COM (Keith Bierman - Sun Tactical Engineering) (10/28/88)

In article <8420@cit-vax.Caltech.Edu> joe@cit-vax.Caltech.Edu (Joe Beckenbach) writes:

	   Do any shells out there (besides sh) handle redirecting stderr
   INDEPENDENT of stdout? 

ksh, as supplied by Cydrome did. I think it is part of the ksh defn.
Keith H. Bierman
It's Not My Fault ---- I Voted for Bill & Opus

aida@porthos.csl.sri.com (Hitoshi Aida) (10/29/88)

Also, is there any good way to send message to stderr in csh?
I mean just like
	echo "$1 not found" >&2
in sh.
--------
Hitoshi AIDA
Computer Science Lab, SRI International

levy@ttrdc.UUCP (Daniel R. Levy) (10/29/88)

In article <75092@sun.uucp>, khb%chiba@Sun.COM (Keith Bierman - Sun Tactical Engineering) writes:
> 	   Do any shells out there (besides sh) handle redirecting stderr
>    INDEPENDENT of stdout? 
> ksh, as supplied by Cydrome did. I think it is part of the ksh defn.

Yes it's part of the ksh definition.  That's because ksh is a 99-44/100%
upward-compatible superset of /bin/sh.

(What's _tactical_ engineering?  Is that a skunkworks-type operation?)
-- 
|------------Dan Levy------------|  THE OPINIONS EXPRESSED HEREIN ARE MINE ONLY
| Bell Labs Area 61 (R.I.P., TTY)|  AND ARE NOT TO BE IMPUTED TO AT&T.
|        Skokie, Illinois        | 
|-----Path:  att!ttbcad!levy-----|

guy@auspex.UUCP (Guy Harris) (10/29/88)

>	   Do any shells out there (besides sh) handle redirecting stderr
>   INDEPENDENT of stdout? 
>
>ksh, as supplied by Cydrome did. I think it is part of the ksh defn.

Either "ksh" stands for "Korn shell", in which case it doesn't really
count - the Korn shell is supposed to be basically upward-compatible
with the Bourne shell, so it handles redirecting stderr independently of
stdout because the Bourne shell does - or it doesn't stand for "Korn
shell", in which case

	1) its creator should have thought of a better name, to avoid
	   confusion

and

	2) some additional information on what this "ksh" is might be
	   interesting.