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

and

ruby script.rb | more

but neither seem to work.

link|improve this question

feedback

1 Answer

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.

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

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.