Restrict an R code to a certain local machine

1

Does anyone know if it is possible to restrict the execution of a certain code created in R to a certain local machine? If so, what would be the code?

    
asked by anonymous 13.06.2018 / 23:39

1 answer

3

The Sys.info() command returns system information, including the name of the machine on the network ( nodename ).

    Sys.info()
#                         sysname                      release 
#                       "Windows"                      "7 x64" 
#                         version                     nodename 
#    "build 7601, Service Pack 1"                "TBRDBZVRLZ1" 
#                         machine                        login 
#                        "x86-64"                     "tbrvlj" 
#                            user               effective_user 
#                        "tbrvlj"                     "tbrvlj" 

With this command you can identify nodename and include a conditional in your code:

nname <- Sys.info()['nodename']

if(nname == 'TBRDBZVRLZ1') {

  print("executa o código")

} else {

  print("não executa o código")

}
#    [1] "executa o código"
    
14.06.2018 / 13:13