I would like to create a script in R that pings a given website. I haven’t found any information about this specific for R.
To start with, all I need is the information on whether the website responses to the ping or not.
Does anyone have information about existing scripts or which package best to use to start with?
We can use a
system2call to get the return status of the ping command in the shell. On Windows (and probably linux) following will work :If you want to capture the output of ping, you can either set
stdout = "", or use a system call:using the option
intern = TRUEmakes it possible to save the output in a vector. I leave it to the reader as an exercise to rearrange this in order to get some decent output.