On 02.11.2010 15:16, Ralph Olsson wrote:
Hello,

I help to maintain a moderate library of R code. In this code we have a number
of calls to the system function along the lines of:

     exe_output = system("./executable.exe",intern=T)

We tend to prefer system() over shell() because, provided the executable has
been compiled and the working directory set, the command works under both linux
and windows.

We've never had a problem with this code using R 2.9 and lower, but I've
recently started testing code in R 2.12 and have been getting "CreateProcess
failed to run..." error messages.

I've not found much info on this in the change logs/release notes, but from what
I have found I am under the impression that system() no longer "shell quotes"
the command passed to it (if I "shQuote()" the command the code runs fine). I
also see from the help files that a new function "system2()" has been introduced
which takes a different set of arguments and appears to be under development
(from the help page: "system2is the beginnings of a more portable interface than
system").

Since I assume there to be good reasons for this change to system I'm happy to
spend the time updating our library to work under R 2.12, but before I commence
on this task I wanted to try to get a better understanding of what changes have
been made to system().

My questions are:

1) What is the nature of and motivation for the changes to the system()
function?

Many, one of them is that system() had different behaviour under Linux vs. Windows.



2) What does system2() offer that system does not?

Portability.


3) Can anyone recommend the "best" (in particular most future-proof) way of
updating our system calls, preferably, and this may be a big ask, such that they
work in both R 2.9 and R2.12 under both linux and windows?

If it should work for R < 2.12.0, then use system() and add, at least for Windows, a shell command (such as "cmd") that allows the executable to run under the Windows command shell. Or better, use shell() right away, you need to special case for Windows anyway.

Best,
Uwe Ligges


If any of these questions have previously been answered and I've simply failed
in my googling, links would be appreciated.

Many thanks for your time,

Ralph
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to