Scala scripting on Windows


#1

I’m troubling running script.

  • Is it possible to have spaces in scala bat script on Windows ?
  • When my script ends some process are still running !

I can’t find tuto dealing with seting up and run script on Windows.

Thanks for reading


#2

probably running with -nocompdaemon will fix that part. (if not, we’ll need more details)


#3

Thanks for the -nocompdeamon option


#4

This is what I used in the past. Not sure about the option above.

 ::#!
@echo off
call scala %0 %*
goto :eof
::!#
object HelloWorld extends App {
  println("Hello, world! " + args.mkString(","))
}

#5

I notice that when I pass to scala.bat only the name and extension without the whole path like this :

::#!
@echo off
call scala “%~nx0” %*
goto :eof
::!#

then I can have scripts in directories containing spaces in their names.
If i use %0 the path to the script cannot contain spaces.
In both case the name connot contains spaces. scala.bat seem’s to consider part of the name after the space as arguments even with the quotes.

Is there a solution ?


#6

In the script before the call scala ... you could probably copy the source file to the same name but substitute dashes or underscores in the file name and then pass that filename to call scala as the first arg.

Seems like a lot of work though unless you can’t change the filename for some reason.


#7

Thank you very much. It works fine like this :

::#!
@echo off
copy “Script with spaces.scala.bat” Script_without_spaces.scala
call scala -nocompdaemon Script_without_spaces.scala %*
del Script_without_spaces.scala
goto :eof
::!#