Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] stdin/stderr redirection under Solaris





On Thu, 26 Aug 2004, Jean-Christian Imbeault wrote:

>
> Steve Smith wrote:
>
> >
> > What shell are you trying to use?
> >     echo $SHELL
> > should tell you.
>
> I'll use whatever shell makes this easiest :) And is normally installed
> on Solaris. I thins I have at least access to csh, tcsh, bash, sh.
>
> Jc
>
Bourne, Korn and csh are usually on Solaris.  I think you're
trying to do this from the command line, so what shell you
get as a login shell is determined by your login.  That's
what echo $SHELL will tell you.

I wrote a simple test script in bourne shell.  This sends
the string 'std err' to stderr and 'std out' to stdout.
#!/bin/sh
echo std err 1>&2
echo std out

and for csh/tcsh did this:
( t.sh | cat > f1) |& cat > f2

This uses cat to send stdout to f1 and stderr to f2.  The
first '|' sends stdout to the first cat, but does nothing
with stderr.  the ()'s fork another process and the '|&'
appends stderr to stdout and sends that to the second cat.

betty,sjs:~/ > cat f1
std out
betty,sjs:~/ > cat f2
std err

for bourne/korn/bash the syntax is much easier because you
can redirect based on the file number:
sh-2.05b$ (t.sh | cat > f1) 2>&1 | cat > f2

and again, you can see stdout is in one file and stderr
is in the other.

sh-2.05b$ cat f1
std out
sh-2.05b$ cat f2
std err

Your process would replace the 'cat > f*' above. This is
what you were trying to do, right?

Steve S.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links