On Tue, 30 Jun 2009, Erin Hodgess wrote:

Dear R People:

Does the system function return a code, (maybe zero if ok, non-zero
otherwise), please?


Let's see
a<-system("ls")
str(a)
 int 0
a<-system("ls foo")
ls: foo: No such file or directory
str(a)
 int 256

Sure looks like it.  And the help page seems to agree, too:

If intern = FALSE, the return value is an error code (0 for success), given the 
invisible attribute (so needs to be printed explicitly). If the command could 
not be run for any reason, the value is 256*127 = 52512. Otherwise if wait = 
TRUE the value is 256 times the error code returned by the command, and if wait 
= FALSE it is 0 (the conventional success value).

     -thomas

Thomas Lumley                   Assoc. Professor, Biostatistics
tlum...@u.washington.edu        University of Washington, Seattle

______________________________________________
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