I am trying to run compile below function in scala
import java.io.{File, PrintWriter, StringWriter}
def runCommand(cmd:String):(Int,String)={
try {
logger.info(String.format("Trying to run the following bash command: [%s]", cmd))
import sys.process._
val intResult:Int = cmd !
val stringResult:String = cmd !!
(intResult, stringResult)
}
catch {
case e: Exception => {
logger.error(String.format("Error in running the following bash command: [%s], Program exits!", cmd))
val sw = new StringWriter
e.printStackTrace(new PrintWriter(sw))
System.out.println(sw.toString)
sys.exit(1)
}
}
(1,"1")
}
But, I am getting below error:
[ERROR] [Error] C:\Users\cp740539\IdeaProjects\sparkscala\src\main\scala\au\com\optus\bdp\conversion\PurgingPartitions.scala:213: overloaded method value !! with a
lternatives:
(log: scala.sys.process.ProcessLogger)String <and>
=> String
cannot be applied to (Int, String)
I am not sure what is the cause of the erro?