I want to issue a native system command from a Scala program, and perhaps trap the output. (\"ls\" comes to mind. There may be other ways to get directory information without is
You can do it using sys.process
easily:
Executing system commands and getting their status code (exit code):
import sys.process._
val result = "your_command" !
println("result = "+result) // result contain zero for success or non zero for fail
Getting output from system commands:
import sys.process._
val result = "your_command" !!
println("result = "+result) // result contain output from the command
You have several other options (pipeline, Redirect STDOUT, Append to STDOUT and ...), you can see this link.