I want to run my process from scala, with several environment variables modified. For example:
Seq("bash","echo $asdf") !
and $asdf set to some value. Is there a way to do this from scala?
EDIT:
The closest I got to it so far:
val pb = new java.lang.ProcessBuilder("bash","echo $asdf")
pb.environment.put("asdf","value") }
val p = pb.start()
io.Source.fromInputStream(p.getInputStream).getLines.toList.foreach(println)
p.waitFor()
But this is ugly.
import java.util._
Runtime.getRuntime().exec("echo $PATH")
– Redheadedsys.runtime
. – Hatching