2014-06-20 19 views
6

dolu mutlak yolunu gerektirecek şekilde görünüyor:Çalıştır kabuk komutları böyle beklendiği gibi çalıştı, ben Mac üzerinde kabuk komutları çalıştırmayı denediğinizde komutu

scala> import scala.sys.process._ 
import scala.sys.process._ 

scala> """protractor --version"""! 
warning: there were 1 feature warning(s); re-run with -feature for details 
Version 0.24.0 
res12: Int = 0 

scala> 

Ama bunu yaparsam Ben t tedarik etmek zorunda

scala> import scala.sys.process._ 
scala> """C:\Users\twer\AppData\Roaming\npm\protractor.cmd --version"""! 
warning: there were 1 feature warning(s); re-run with -feature for details 
Version 0.24.0 
res11: Int = 0 

scala> 

: Ben Windows üzerinde böyle yapmak zorunda gibi

scala> import scala.sys.process._ 
import scala.sys.process._ 

scala> """protractor --version"""! 
warning: there were 1 feature warning(s); re-run with -feature for details 
java.io.IOException: Cannot run program "protractor": CreateProcess error=2, The system cannot find the file specified 
     at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041) 

Öyle görünüyor: Windows üzerinde, bu alın Komuta tam mutlak yolu.

Ancak, komutun yolda mevcut olduğundan eminim. Bundan kaçınmak için zaten var mıdır?

cevap

9

Bu deneyebilirsiniz:

val command = Seq("protractor", "--version") 
val os = sys.props("os.name").toLowerCase 
val panderToWindows = os match { 
    case x if x contains "windows" => Seq("cmd", "/C") ++ command 
    case _ => command 
} 
panderToWindows.! 
İlgili konular