[R] computer name

Thomas Levine thomas.levine at gmail.com
Mon Jun 13 06:12:46 CEST 2011


Not exactly R, but how about

> pcname <- system('uname -n',intern=T)

Tom

On Sun, Jun 12, 2011 at 11:19 PM, pdb <philb at philbrierley.com> wrote:
>
> Is there an r function that will be able to identify the computer the code is
> running on?
>
> I have some common code that I run on several computers and each has a
> database with a different server name - although the content is identical.
>
> I need to set thisServer depending on which machine the code is running
> on...
>
> something like...
>
> if(pcname = pc1) thisServer = 'SERVER1'
> if(pcname = pc2) thisServer = 'SERVER2'
>
>
> conn <- odbcDriverConnect("driver=SQL Server;database=x;server=thisServer;")
>
> ...rest of code will now run OK.
>
> I know I could set the DSN names the same and use...
>
> conn <- odbcConnect("commonDSNname")
>
>  but I was wondering if there was another way
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/computer-name-tp3593120p3593120.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list