Hi,
I’m trying to use Process to run system commands and it doesn’t seem to work. I seem to recall that this worked previously, but I could find my old code. For example to make a directory, in the REPL I do the following:
scala> import sys.process._
import sys.process._
scala> Process("md tt")!
But I get the following warning and nothing happens:
warning: there was one feature warning; re-run with -feature for details
java.io.IOException: Cannot run program "md": CreateProcess error=2, The system
cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:69
)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl
.scala:98)
at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang(ProcessBuilderIm
pl.scala:112)
... 33 elided
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find th
e file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 37 more
If I exit the REPL and in the same command prompt do
D:\scala\temp>md tt
It works as expected. I recently upgraded to Windows 8.1 and I’m thinking maybe there is some permission for java that is not set correctly.
Any ideas?
Thanks,
Mike
Are you sure md
is a genuine executable and not a Windows shell builtin? Is there an “md.exe” somewhere and is it on your path?
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
I figured it out. The correct syntax is ot include a /C after the cmd as:
scala> Process("cmd /C md \\tt")!
res9: Int = 0
Thanks,
Mike