[R-SIG-Mac] Identifying computer from R

Dennis Fisher ||@her @end|ng |rom p|e@@th@n@com
Sat May 27 00:36:06 CEST 2023


Iris

Thanks for the tip.
This works:
	Sys.info()["nodename"]

Dennis

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com




> On May 26, 2023, at 3:27 PM, Iris Simmons <ikwsimmo using gmail.com> wrote:
> 
> Hi,
> 
> 
> I think PS1 is generally a bash environment variable. So if you're not opening your R session from a bash session, then PS1 is likely undefined.
> 
> You could perhaps use `Sys.info()` instead if you wish to determine which computer of yours is running the code.
> 
> On Fri, May 26, 2023 at 6:15 PM Dennis Fisher <fisher using plessthan.com> wrote:
> R 4.2.3
> OS X
> 
> Colleagues 
> 
> Interesting (minor) problem.  I have code that I run automatically on two different computers.  The code runs from Dropbox so there is not separate code for each computer.
> 
> In order to identify which computer is running the code, I was hoping to do something like:
>         Sys.getenv(SOMETHING)
> 
> In a terminal window:
>         echo $PS1
> returns the prompt on that particular computer.
> 
> However, when I attempt to access that from R, I am not successful.  For example:
> 
> In a terminal:
>         echo $PS1
> returns:
>         PET\!>
> 
> In R:
>         Sys.getenv("PS1")
> returns:
>         ""
> 
> In R:
>         system("echo $PS1") 
> returns an empty line.
> 
> A solution to this immediate problem (how to obtain that environment variable in R) or any other clever way to identify a particular computer would be much appreciated.
> 
> Dennis
> 
> 
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone / Fax: 1-866-PLessThan (1-866-753-7784)
> www.PLessThan.com
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list