Since Scala has so many cool stuff I was thinking it may have something that makes capturing a process's output easy. I know the Java way of doing that, but I thought about asking for another way.
scala> scala.tools.nsc.io.Process("ls -1 /tmp | wc").stdout foreach println
41 63 770
Or there's a repl command:
scala> :sh cat /etc/passwd | wc
stdout: List[String] = List( 65 185 3667)
Shipping any IO code with 2.8 was going to require overcoming more stop energy than I can beat, so I put it all in the compiler. Plenty of reasonably useful stuff in scala.tools.nsc.io.
As of Scala 2.9, you can do:
import scala.sys.process.Process
println(Process("uname -a").!!.contains("x86_64"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With