Groups
Groups
Sign in
Groups
Groups
scala-user
Conversations
About
Send feedback
Help
Scala - System Command - problem with single quotes
141 views
Skip to first unread message
BHLB
unread,
Dec 19, 2012, 3:53:56 PM
12/19/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 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
unread,
Dec 19, 2012, 4:04:37 PM
12/19/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 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
unread,
Dec 19, 2012, 5:08:17 PM
12/19/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 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")).!
Reply all
Reply to author
Forward
0 new messages