Mailing List Archive


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

Re: [tlug] stdin/stderr redirection under Solaris



>>>>> "Jean-Christian" == Jean-Christian Imbeault <jean-christian.imbeault@example.com> writes:

    Jean-Christian> Sorry since this is not a Linux only question, but
    Jean-Christian> I've been having a hell of a time trying to figure
    Jean-Christian> out how to redirect stdout and stderr separately
    Jean-Christian> under Solaris (in any shell).

It's a shell question, not an OS question.  Your best bet is to use a
Bourne shell, in which case file redirection use the syntax "prog N>
file" where N is the file descriptor and defaults to 1.  The syntax &M
duplicates file descriptor M into an "lvalue", so that "prog N>&M"
sends both N and M to wherever N was at the time.  Note that it is a
duplication, not an identification, so that "prog 1> file 2>&1" send
both stdout and stderr to file, while "prog 2>&1 1>file" sends stdout
to file and stderr to stdout (this actually has semantics: stderr is
now buffered, where normally it is not).

I don't think any of the shells have syntax for sending different FDs
to different pipes; use the "y" program for that.  However, I don't
see a "y" program on Debian or an old Red Hat Linux.  If you need two
"consoles", you could use something like

prog 1> tmp1 2> tmp2 &

and

tail -f tmp1
tail -f tmp2

in the separate consoles.

-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links