fqdn
By Steph Locke
斯蒂芬·洛克(Steph Locke)
This is just a quick post, to mention how you can get your computer name with the domain it is registered in i.e. Â the fully qualified domain name (FQDN) by using R.
这只是一篇简短的文章,提到了如何使用R获得注册域名的计算机名称,即完全合格的域名(FQDN)。
基数R (Base R)
In Windows to get the computer name in it’s fully qualified form you need to do:
在Windows中,以完全限定的格式获取计算机名称,您需要执行以下操作:
paste(Sys.getenv("COMPUTERNAME"), Sys.getenv("USERDNSDOMAIN"), sep=".")
paste(Sys.getenv("COMPUTERNAME"), Sys.getenv("USERDNSDOMAIN"), sep=".")
In Linux, you can use:
在Linux中,您可以使用:
Sys.getenv("HOSTNAME")
Sys.getenv("HOSTNAME")
Each of these returns an empty string in the other OS so you can concatenate them to get the FQDN.
这些中的每一个在另一个OS中都返回一个空字符串,因此您可以将它们串联以获取FQDN。
getFQDN <- function (){ tolower( paste0( paste(Sys.getenv("COMPUTERNAME"), Sys.getenv("USERDNSDOMAIN"), sep=".") , Sys.getenv("HOSTNAME") ) ) } getFQDN()
getFQDN <- function (){ tolower( paste0( paste(Sys.getenv("COMPUTERNAME"), Sys.getenv("USERDNSDOMAIN"), sep=".") , Sys.getenv("HOSTNAME") ) ) } getFQDN()
翻译自: https://www.pybloggers.com/2016/01/fqdn-fully-qualified-domain-names-in-r/
fqdn