Re: [R] computer name
Erich Neuwirth erich.neuwi...@univie.ac.at on Mon, 13 Jun 2011 11:16:08 +0200 writes: This depends on your OS. on Windows, Sys.getenv('computername') should work. Sys.info()['nodename'] should work on all systems. yes, indeed! BTW: Learn something more by considering the slight variation Sys.info()[['nodename']] which is what you typically really want (and which will be very very slightly more efficient in typical use cases). Martin Maechler, ETH Zurich On 6/13/2011 7:38 AM, David Scott wrote: On 13/06/11 15:19, pdb 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@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. Does Sys.info()[nodename] give you what you want? David Scott __ 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. __ 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.
Re: [R] computer name
This depends on your OS. on Windows, Sys.getenv('computername') should work. Sys.info()['nodename'] should work on all systems. On 6/13/2011 7:38 AM, David Scott wrote: On 13/06/11 15:19, pdb 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@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. Does Sys.info()[nodename] give you what you want? David Scott __ 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.
Re: [R] computer name
Not exactly R, but how about pcname - system('uname -n',intern=T) Tom On Sun, Jun 12, 2011 at 11:19 PM, pdb ph...@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@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. __ 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.
Re: [R] computer name
On 13/06/11 15:19, pdb 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@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. Does Sys.info()[nodename] give you what you want? David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 __ 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.