[R] system vs shell wait command

robbert blonk robbert.blonk at gmail.com
Sun Jan 24 13:25:57 CET 2010


Dear All,

I try to invoke a second program (called "gencont") within a R script.
However this second program needs some time to finish. After finishing the
output should be read into R and used for further calculation.

Under windows, it perfectly works:

result<-shell("gencont < yn.txt",intern=TRUE,wait=TRUE) 
# R waits untill the program finishes (apporx 3 min) and uses the result as
an object. "yn.txt" contains the answer to a question prompted by the second
program before running
resultf<-result[length(result)] 
# reads the last line, which contains the required result

However, At our Linux server, shell() doesn't work. Here, I'll need
system()...
result<-system("./gencont.exe < yn.txt",intern=TRUE,wait=TRUE) #slightly
different
resultf<-result[length(result)] #same

The problem now is that R under Linux does not wait for the second program
to finish, even if wait = TRUE...how come?
What should I do?

Best regards,
Robbert

-- 
View this message in context: http://n4.nabble.com/system-vs-shell-wait-command-tp1288631p1288631.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list