[R] Sys.getenv
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Thu Jul 12 11:49:37 CEST 2001
Christian Hoffmann <christian.hoffmann at lagonda.wsl.ch> writes:
> I am running R-1.3.0 on Solaris 8:
?? (see below)
>
> Under Solaris I do
> setenv dendro_us hoffmann
>
> echo $dendro_us gives back:
> hoffmann
>
> which is correct.
>
> When in R I do:
>
> Sys.getenv("dendro_us") I get
> dendro_us
> ""
>
> which is NOT correct:
>
> Inverse effect (taken from help of Sys.getenv)
> Under R:
> print(Sys.putenv("R_TEST"="testit", ABC=123))
> [1] TRUE TRUE
> Sys.getenv("R_TEST") gives back:
> R_TEST
> "testit"
> which seems correct.
>
> When in Solaris I do:
> echo $R_TEST
> R_TEST: Undefined variable.
>
> which is NOT correct:
>
> Third type of behaviour:
> echo $HOME
> /home/woodstock/hoffmann
> and
> Sys.getenv("HOME")
> HOME
> "/home/woodstock/hoffmann"
>
> which are both correct.
>
> QUESTION:
> Are there two versions of the environment around? Or what am I missing?
It's not quite clear to me exactly what you're doing, but the thing
that usually confuses people about environments is the following:
Environments exist on a per-process basis. A child process inherits a
*copy* of the parent environment. Making changes to an environment
does not affect the environment of any other running process.
E.g. the following is expected:
> Sys.putenv("FOO"="bar")
> system("echo $FOO")
bar
> q("no")
$ echo $FOO
$
but this should work (parallel to setenv but Bourne shell syntax):
$ BAR=foo ; export BAR
$ R --quiet
> Sys.getenv("BAR")
BAR
"foo"
> >uname -a
> SunOS fluke 5.7 Generic_106541-12 sun4d sparc SUNW,SPARCserver-1000
??? (that'd make it Solaris 7, no?)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list