11

I am using this command to run scala scripts.

spark-shell -i test.scala

At the end of the execution of the script I still see spark-shell running.

I have used ":q/:quit" in the test.scala script to try and exit but it's not working.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Ujjwal SIddharth
  • 137
  • 1
  • 2
  • 10

3 Answers3

9

You need to add exit() at the end of your script to avoid stepping into scala REPL.

Helloworld.scala

print("Hello World");
print("Second Line");
print("Bye now");
System.exit(0)

Run above

spark-shell -i helloworld.scala
Wonko the Sane
  • 754
  • 3
  • 14
  • 31
charles gomes
  • 2,145
  • 10
  • 15
7

In version 2.4.3 System.exit(0) is working.

abhijitcaps
  • 594
  • 8
  • 7
5

I also like the echo :quit | spark-shell ... answer that was offered on another question.

Leif Wickland
  • 3,693
  • 26
  • 43