> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Dennis Fisher
> Sent: Tuesday, August 23, 2011 11:40 AM
> To: r-h...@stat.math.ethz.ch
> Subject: [R] Setting Windows environment variables via a batch file
> 
> R 2.13
> Vista
> 
> Colleagues,
> 
> I have encountered a problem with Windows environment variables that I
> don't understand.  My R code is designed to execute another program
> that uses Intel Fortran.  Intel Fortran apparently has some complicated
> issues regarding environment variables.  As a result, Intel provides a
> batch file (FortranVars.bat) that sets all the environment variables.
> If I am working at a Command Prompt (i.e., at the command line, not in
> R), the following happens:
>       1.  When I open the Command Prompt, I type "set %path%" and I get
> some output
>       2.  I then execute the batch file -  the batch batch file returns
> a message "Intel (R) Visual Fortran ..." indicating that it was
> executed (and there is no error or warning from the OS).
>       3.  If I type "set %path%" again, the output reflects the
> environment variables added by the batch file.
> So far, so good.
> 
> Now I try the same from within R.
>       1.  I type shell("set") and I examine the output for path (for
> unclear reasons, executing shell("set %path%") resulted in a warning:
>               "running command ... had status 1"
>       2.  i then execute the batch file -- same message as before
>       3.  I type shell("set")" -- the output is unchanged.
>       4.  I also tried executing step 2 preceded by "@ call".  no
> success.
> 
> I am not sure where the problem lies (incidentally, the behavior may be
> different in Windows 7 so I would appreciate answers relevant to
> Vista).  Does anybody have any insights?
> 

Dennis,

The "problem" is that when the shell command finishes and returns to R, all 
changes made go away.  The changes only persist while the shell is open.  The 
same thing happens when you open a command prompt outside of R, change the 
path, then close the command prompt.  The next time you open a command prompt 
the changes you made to the path are no longer there.  You will need to provide 
more information on how you are calling your Fortran program, before anyone can 
provide much assistance. 

As for the getting just the path, you can use 

shell('set path')


hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


______________________________________________
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