[R & Unix ..] system("test",...)  gives funny results...
   
    Peter Dalgaard BSA
     
    p.dalgaard@biostat.ku.dk
       
    10 Dec 1998 15:37:41 +0100
    
    
  
Martin Maechler <maechler@stat.math.ethz.ch> writes:
> [in an attempt to provide 
> 
> 	  system.test <- 
> 		function(...) { system(paste("test", ...)) == 0 }
> and then 
> 	  file.exists <- 
> 		function(file){sapply(file, function(f)system.test("-e", f))} 
>  
>   (which would provide S-plus [>= 4.x] compatibility)
> ]
> 
> Look at this -- ``the horror'' to me :
> 
> > (system("test -e /tmp"))
> sh: test: argument expected
> [1] 256
Happens to me on Solaris too, but *not* on Linux!
> Similar funny behavior  (in tcsh; $version gives the tcsh version)
> 
> In the shell
> 
>    sophie{maechler}639> echo $version
>    tcsh 6.04.00 (Cornell) 93/07/03 (sun4) options 8b,nls,dl,al
> 
> In R :
> 
>    > (system("echo $version"))
> 
>    [1] 0
> 
>    > {system("echo $version > /tmp/qq"); scan("/tmp/qq",what="")}
>    Read 0 items
>    character(0)
>    >
Isn't this just because system() uses /bin/sh?
>  {system("echo $USER > /tmp/qq"); scan("/tmp/qq",what="")}
Read 1 items
[1] "pd"
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._