I have a shell script with series of defined steps. I am trying to convert the script to Scala code by maintaining the order of steps. Basically I want my Scala code to be a mirror of the shell script.
I've used sys.process._ library. The shell script has commands like:
mkdir <pathToDir>
hadoop fs -copyToLocal <source> <dest>
rm -r <pathToDir>
java -jar <someScript>
I need to maintain the order of execution of these steps.
I tried something like:
import sys.process._
Class A {
def processMethod(): Unit = {
Process("mkdir -p <dir1>") #| Process("hadoop fs -copyToLocal
<hdfsDir1> <localDir1>") #| Process("mkdir -p <dir2>") #|
Process("hadoop fs -copyToLocal <hdfsdir2>/*.parquet <localDir2>")
#| Process("java -jar <pathToJarFile> -script <sampleScripts> 1>&2")
#| Process("rm -r<localDir1>") #| Process("rm -r <localDir2>") !
}
}
I'm expecting the operations to execute in the order they have been defined. I'm confused about how ProcessBuilder/Process works or if there is an alternative to convert this whole thing to Scala code?