Scala isn't allowing me to execute a batch file whose path contains spaces.Same Java code does.What

Posted by Geo on Stack Overflow See other posts from Stack Overflow or by Geo
Published on 2010-03-13T13:32:34Z Indexed on 2010/03/13 13:35 UTC
Read the original article Hit count: 457

Filed under:
|
|

Here's the code I have:

var commandsBuffer = List[String]()
commandsBuffer ::= "cmd.exe"
commandsBuffer ::= "/c"
commandsBuffer ::= '"'+vcVarsAll.getAbsolutePath+'"'
commandsBuffer ::= "&&"
otherCommands.foreach(c => commandsBuffer ::= c)
val asArray = commandsBuffer.reverse.toArray
val processOutput = processutils.Proc.executeCommand(asArray,true)
return processOutput

otherCommands is an Array[String], containing the following elements:

  • vcbuild

  • /rebuild

  • path to a .sln file

vcVarsAll contains the path to Visual Studio's vcvarsall.bat. It's path is C:\tools\microsoft visual studio 2005\vc\vcvarsall.bat. The error I receive is: 'c:\Tools\Microsoft' is not recognized as an internal or external command, operable program or batch file..

The processutils.Proc.executeCommand has the following implementation:

def executeCommand(params:Array[String],display:Boolean):(String,String) = {
  val process = java.lang.Runtime.getRuntime.exec(params) 
  val outStream = process.getInputStream
  val errStream = process.getErrorStream
  ...
}

The same code, executed from Java/Groovy works. What am I doing wrong?

© Stack Overflow or respective owner

Related posts about scala

Related posts about runtime