How to ping with Python / Linux ?

Posted on 2004-11-25
Last Modified: 2011-08-18
I have to write a script to monitor a mysql connection. Before I do this I want to test if my machine can access Internet by pinging the DNS server of my provider. I have seen very complicated ICMP functions. Does it not exist an obvious and easy to make a ping and return a boolean ?
Question by:proximal
    LVL 9

    Accepted Solution

    Check out:

    He has written ping in pure Python. You can download his code here:

    I tried it in Windows and it seems to work just fine. I ran the following command: 4

    Author Comment

    Thank you for your help. I had found this link with google / python but the code is not very handy. I have found this (better because structurated as a class) :

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
    The purpose of this article is to demonstrate how we can use conditional statements using Python.
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now