1

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.

slhck
  • 235,242
Ramy
  • 1,171

1 Answers1

2

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.

grawity
  • 501,077