Redirect stdout from SBT run to file

dsg picture dsg · Jan 25, 2012 · Viewed 8.6k times · Source

Inspired by the examples on the SBT github page, I'm trying to redirect the stdout produced from a run in SBT's interactive mode to a file.

Here's my failed attempt:

> run #> file('/Users/dsg/temp/temp.txt') !

I've tried both with and without the ! at the end. I've tried both single and double quotes. Nothing works -- it just behaves as if the #> file(... is omitted, things only get printed to stdout, no file is created.

Answer

John Foley picture John Foley · Mar 3, 2013

I'm not an SBT expert, but this doesn't seem to be the correct feature.

> run is interpreting everything after it as file arguments. #> seems to be part of the sbt library, for use inside of your project sbt files, not at their prompt.

Getting around this, I exit sbt, and use my external shell to do this:

$ sbt "run" > run_output.txt