Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6251275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:35:06+00:00 2026-05-24T13:35:06+00:00

I would like to create a script in R that pings a given website.

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:35:07+00:00Added an answer on May 24, 2026 at 1:35 pm

    We can use a system2 call to get the return status of the ping command in the shell. On Windows (and probably linux) following will work :

    ping <- function(x, stderr = FALSE, stdout = FALSE, ...){
        pingvec <- system2("ping", x,
                           stderr = FALSE,
                           stdout = FALSE,...)
        if (pingvec == 0) TRUE else FALSE
    }
    
    # example
    > ping("google.com")
    [1] FALSE
    > ping("ugent.be")
    [1] TRUE
    

    If you want to capture the output of ping, you can either set stdout = "", or use a system call:

    > X <- system("ping ugent.be", intern = TRUE)
    > X
     [1] ""                                                         "Pinging ugent.be [157.193.43.50] with 32 bytes of data:" 
     [3] "Reply from 157.193.43.50: bytes=32 time<1ms TTL=62"       "Reply from 157.193.43.50: bytes=32 time<1ms TTL=62"      
     [5] "Reply from 157.193.43.50: bytes=32 time<1ms TTL=62"       "Reply from 157.193.43.50: bytes=32 time<1ms TTL=62"      
     [7] ""                                                         "Ping statistics for 157.193.43.50:"                      
     [9] "    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss)," "Approximate round trip times in milli-seconds:"          
    [11] "    Minimum = 0ms, Maximum = 0ms, Average = 0ms"         
    

    using the option intern = TRUE makes 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create a script that will create a border around specific
I would like to create a pipe in a ksh script (using exec) that
I would like to create a command line application that accepts a script F-Script
I'd like to create a small script that basically does this: run program1.exe -->
I would like to create a script, that will play for me a facebook
As a project I would like to create a website that allows a user
I would like to write a python script that would upload any file I
I would like to create a script that would add an AD account, but
I would like to create a batch script, to go through 20,000 links in
I would like to create a WLST script to create my Weblogic domain. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.