Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to redirect persistently stderr to /dev/tty12 so error messages do not touch my nerves when doing something in tty1.

The redirection should go through init.d or ~/.bashrc or ~./bash_profile. Just once.

Can it be done and how?

share|improve this question

Seems like a really bad idea, and I doubt that the system provides a way to do it.

Whenever a process is created, the calling process determines where its stdin, stdout, and stderr will be directed. There would have to be a general way to override that -- and it would break any mechanisms that redirect stderr explicitly.

For example, if you type:

some_command >some_command.out 2>some_command.err

should some_command's stderr go to some_command.err, or to /dev/tty12?

The closest thing I can think of is to invoke a shell with its stderr redirected:

bash -l 2>/dev/tty12

In my (brief) experiments (redirecting to a file rather than to a tty), this causes the shell to be non-interactive. Adding -i forces it to be interactive -- but the shell prompt is apparently printed to stderr.

Of course you can redirect stderr for individual commands (assuming you're not using csh or tcsh):

some_command 2>some_command.err

and you could define a shell function that does this for you:

e() { "$@" 2>/dev/tty12 ; }

Then, for each command whose stderr you want redirected, just prepend e to the command:

e some_command
share|improve this answer

Many shells write their interactive prompts to stderr, so you are likely to have trouble interacting with a shell if you redirect it's stderr to /dev/tty12. Also, error messages are important. Why ignore them?

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .