2

I'm busy writing up a Capistrano deployment script for one of our applications. One of the steps installs RVM using the following command:

run "cat ~/rvm-installer.sh | bash -s stable --ruby"

However, I feel the output is too verbose, and I rather want to dump it into a .log file. Is it possible to redirect the output for the entire rvm-installer.sh script elsewhere?

josef.van.niekerk
  • 11,941
  • 20
  • 97
  • 157

1 Answers1

3

Like this:

run "cat ~/rvm-installer.sh | bash -s stable --ruby >out.log"

or, if you want to redirect standard error stream of the process as well:

run "cat ~/rvm-installer.sh | bash -s stable --ruby >out.log 2>err.log"

you can also redirect everything to the same file:

run "cat ~/rvm-installer.sh | bash -s stable --ruby >out.log 2>&1"
piokuc
  • 25,594
  • 11
  • 72
  • 102
  • Awesome, can I get it to not print to screen, as this works, but I'm still seeing the screen output? – josef.van.niekerk Mar 13 '13 at 10:39
  • If you don't want to see anything you can run Capistrano with option `--quiet` – piokuc Mar 13 '13 at 10:42
  • If you want to redirect everything in the same file, then you must redirect stdout _before_ stderr, like this `> out.log 2>&1`. When you do `i>&j`, it means all output of file pointed to by _i_ gets sent to file pointed to by _j_. Redirection are performed from left to right. When you first redirect stderr to the same file pointed by stdout, then stderr points to console output. After, when you redirect stdout to the file `out.log`, it does change stderr which still points to console output. More info on http://www.tldp.org/LDP/abs/html/io-redirection.html – cbliard Mar 13 '13 at 11:32