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

When I'm running my ruby script, I'm getting an exception. However, since I'm running Ubuntu in VMware Fusion, I can't resize my terminal window so I can't see the whole excecption.

How can I view the whole thing?

I've tried

ruby script.rb > out.txt


ruby script.rb | more

but neither seem to work.

share|improve this question
up vote 2 down vote accepted

In Unix, normal program output is usually written to the stdout stream and errors go to stderr. (Input is called stdin.)

  • In sh/bash shells (also in Windows cmd.exe), use 2> to redirect stderr:

    ruby script.rb >out.txt 2>err.txt

    To point both to the same place, 2>&1 can be used:

    ruby script.rb >out.txt 2>&1 # (order matters)
    ruby script.rb 2>&1 | more
  • In bash, use >& to redirect both at once:

    ruby script.rb >& out.txt
    ruby script.rb |& more

In most Linux terminals you can use Shift+PageUp and Shift+PageDown to scroll the text.

share|improve this answer
perfect. thanks for the great explanation. – Ramy Dec 9 '11 at 13:04

You must log in to answer this question.

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