shell & less questions

I have a program that writes messages to stderr using write() to file
descriptor 2. I want to pipe that to ‘less’. Shouldn’t
program 2| less
work? It doesn’t. I can do
program 2>&1 | less
but I really don’t want to see the standard output on the less screen.

What is the proper syntax to pipe stderr only to another program?

New question:

I’m running a program that continually generates output. I’m pipeing
that program to less. Sometimes it generates many lines and I just want
to see what’s coming out NOW. I.E. I want to jump to the end of the pipe
as it exists right now. The pipe may now be very large. My understanding
is that if I type
'&
in less it should jump to the end of the pipe. But it never seems to
finish. I don’t think the first program is generating data faster then
less can read it while NOT displaying it.

How can I jump to the end of the pipe as of right now while the pipe is
still being filled with data?

Added explanation:

In case your interested, the program in question monitors network traffic.
It is normally run to see good status information. That prints out on
stdout.

The program also prints out error messages when it spots a network error.
Sometimes the network error are cronic. They don’t stop. So as I’m
fiddeling with other things on the network I want to look and see if its
working now. I don’t care about all of the messages that printed in the
last 15 minutes. I want to see what, if any, error messages are coming
out now. BUT, based on what I see now, I may want to scroll back a minute
or two.

TIA

Bill Caroselli <qtps@earthlink.net> wrote:

I have a program that writes messages to stderr using write() to file
descriptor 2. I want to pipe that to ‘less’. Shouldn’t
program 2| less
work? It doesn’t. I can do
program 2>&1 | less
but I really don’t want to see the standard output on the less screen.

What is the proper syntax to pipe stderr only to another program?

I do not think this can be done with ksh. Some other shell might
allow it, but ksh doesn’t.

(Well, if you used a named pipe with mkfifo, you might be able to set
something up – but that probably isn’t what you’re looking for.)

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com

Bill Caroselli <> qtps@earthlink.net> > wrote:
I have a program that writes messages to stderr using write() to file
descriptor 2. I want to pipe that to ‘less’. Shouldn’t
program 2| less
work? It doesn’t. I can do
program 2>&1 | less
but I really don’t want to see the standard output on the less screen.

Where do you want the standard output to go?

If you want to redirect it to a file, it’s quite simple:

program 2>&1 > /dev/null | less

What is the proper syntax to pipe stderr only to another program?

If you want to leave stdout pointing to the terminal (which, BTW, doesn’t
sound like a good idea if the other program is less), you can redirect it to
the original stderr:

program 3>&2 2>&1 >&3 3>&- | less