Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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