I am able to ping an IP with pingr with the following code:
ping("10.0.4.101")
But I am not able to ping another IP with pingr with the following code:
ping("10.151.2.101")
Even though I am able to ping 10.151.2.101 through cmd:
Any advice would be appreciated, thanks!
CodePudding user response:
A bit of debugging shows that pingr
won't work if the response time is too short, or if the locale isn't english.
ping <- function (destination, continuous = FALSE, verbose = continuous,
count = 3L, timeout = 1)
{
if (!continuous && verbose) {
stop("'!continuous' && 'verbose' does not work currently")
}
os <- ping_os(destination, continuous, count, timeout)
status <- run(os$cmd[1], os$cmd[-1], error_on_status = FALSE)
output <- strsplit(status$stdout, "\r?\n")[[1]]
if (!continuous) {
timings <- grep(os$regex, output, value = TRUE, perl = TRUE)
times <- sub(os$regex, "\\1", timings, perl = TRUE)
res <- as.numeric(times)
length(res) <- count
res
}
else {
invisible()
}
}
timings
are evaluated with following regex :
os$regex
[1] "^.*time=(. )[ ]?ms.*$"
Obviously, time<1ms
won't work as grep
is looking for time=
, filed an issue.
CodePudding user response:
If pingr
is not delivering I would just send the command directly to the shell:
system('ping("10.151.2.101")')