[lug] How to redirect a program that writes to tty?

Davide Del Vento davide.del.vento at gmail.com
Fri Oct 29 18:10:18 MDT 2010


(note: I asked this very question here, if you prefer to answer on a
public site:
http://stackoverflow.com/questions/4056075/ )

If you prefer the mailing list, here it is the problem:


This is the un-redirected output (if you don't know what module is, it
doesn't matter much):

$ module help null

----------- Module Specific Help for 'null' -----------------------

        This module does absolutely nothing.
        It's meant simply as a place holder in your
        dot file initialization.

        Version 3.2.6

Suppose I'd like to redirect that to a file....

$ module help null > aaa.txt

----------- Module Specific Help for 'null' -----------------------

        This module does absolutely nothing.
        It's meant simply as a place holder in your
        dot file initialization.

        Version 3.2.6

$ cat aaa.txt
$

Well, it must be on the stderr

$ module help null 2> aaa.txt
        This module does absolutely nothing.
        It's meant simply as a place holder in your
        dot file initialization.

        Version 3.2.6

$ cat aaa.txt

----------- Module Specific Help for 'null' -----------------------
$

Hey! It is resetting my redirect. This is really annoying, and I have
two questions:

   1. How can I achieve what I want, namely redirecting everything into my file
   2. Why are they doing such a weird thing?

Thanks,
Dav



More information about the LUG mailing list