What would be the most robust way to test if your internet is connected to wifi or ethernet in R
?
I want to do an if
statement, something like:
if (internet == "wifi") {
return(x)
} else if (internet == "ethernet") {
return(y)
} else { #no internet
return(z)}
system("ipconfig", intern = T)
seems to be useful but I'm not sure what to extract so that it correctly identifies wifi/ethernet each time no matter what the connection setup is.
I'm working in a windows
environment.
thanks
My code is not the most beautiful but it will return a data frame where you can simply read the connection status based on the column "Status" and "Interface Name". The main problem is that you might end up with various Ethernet/WiFi configurations and therefore it is quite complicated to parse ipconfigs output.
My version is based on the simple shell command
netsh interface show interface
Here is the code: