[R] passing username and password to source()

Dieter Menne dieter.menne at menne-biomed.de
Thu Feb 14 08:18:19 CET 2008


[Ricardo Rodriguez] Your XEN ICT Team <webmaster <at> xen.net> writes:


> But considering I am just newbie, could you point me to any example to 
> get this working? Thanks!
> 

I was thinking of something like this (note: you must store PassEnv2.r on disk
as a file).


# File PassEnv.r
Sys.setenv(PASSW="mypass")
source("PassEnv2.r")
Sys.unsetenv("PASSW")
# Try again (to show it's removed)
source("PassEnv2.r")


#File PassEnv1.r
passw=Sys.getenv("PASSW")
# Sys.unsetenv("PASSW") ## This would also be possible to clear the enviroment
# Show that is worked
cat("The password is ",passw,"\n")


Again: this is good for your own computer, but should not be used when security
constraints are relevant. The password is visible to everyone for the time of
passenv1.r running.


Dieter



More information about the R-help mailing list