blue-sky blue-sky - 28 days ago 4x
Scala Question

Return value of process to String

I'm attempting to return the source of a page using the wget command to String using command :

val url: String = ""
import sys.process._
val result: String = ("wget -qO- " + url !).toString
println("result : " + result);

but return value is 0. This is output of code :

result : 0

How to access the return value of
in a variable , in this case the source value of the url ?


! returns the exit code of the process (0 in your case). If you need the output of the process you should use !! instead:

val url = ""
import sys.process._
val result = ("wget -qO- " + url !!).toString
println("result : " + result)

(relevant documentation)