Scala - System Command - problem with single quotes

141 Aufrufe
Direkt zur ersten ungelesenen Nachricht

BHLB

ungelesen,
19.12.2012, 15:53:5619.12.12
an scala...@googlegroups.com
Here is my problem: I want to execute an R script in batch mode from scala. Here is the code I try to use:

    import scala.sys.process._
    "R CMD BATCH --no-save --no-restore '--args a=1' /path/test.r".!

The command works when I cut and paste it in a terminal. But when I try it through scala, '--args is interpreted as the script file and I receive the Fatal error :

    Fatal error: cannot open file ''--args': No such file or directory

Everything works if I remove the argument block:

    import scala.sys.process._
    "R CMD BATCH --no-save --no-restore /path/test.r".!

Any guess on how to restore the expected "normal" execution?

Thanks in advance,

BHLB

Josh Suereth

ungelesen,
19.12.2012, 16:04:3719.12.12
an BHLB, scala-user
Use these Seq() based API.

sys.process.Prcoess(Seq("R", "CMD", "BATCH", "--no-save", "--no-restore", "--args a=1", "/path/test/r").!

At least, IIRC, that's the syntax....

BHLB

ungelesen,
19.12.2012, 17:08:1719.12.12
an scala...@googlegroups.com

Thanks a lot. It now works.

sys.process.Process(Seq("R", "CMD", "BATCH", "--no-save", "--no-restore", "--args a=1", "/path/test.r")).!
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten