Thread: Ping

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11

    Ping


    Hi All

    Do any one know how to write a programme in python to ping one or more than one Pc's and print ok to successful no to unsuccessful. An example would be great.

    Thanks
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    I googled this:
    http://pynms.sourceforge.net/

    You will find a ping module there.

    Grim
  4. #3
  5. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    This link has a Python 1.4 module for ping and traceroute.
    http://www.python.org/~jeremy/python.html

    You may need to do some conversion work.

    grim
  6. #4
  7. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    I coded one not to long ago.. if ya still need it.. let me know and i will look fo it for ya
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    11
    HI xlordt

    It will be graet if you could post the cade

    Thanks
  10. #6
  11. Only the strong survives!!.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Feb 2003
    Location
    A World of wonders.
    Posts
    5,583
    Rep Power
    407
    Code:
    import os
    
    for x in file( "adress.txt" ):
    
        address, ports = x.strip( ).split( ":" )
        Ping  = os.system( "ping -w 1 -a " + address + " > null.txt" )
    
        if Ping == 1:
            print address, "\t[Not Good]"
        else:
            print address, "\t[Yes Good]"
    I hade a better one, but i cant find it.. i know i put it in one of my floopys.. so i will look for that one laters.. this one i coded it at a friends house.. cause im not home.. but if this will do you.. then kool... else let me know and i will look for it when i get home laters good luck, btw this works on windows.. on linux i would use > /dev/null.. dont know if windows has one
    Last edited by xlordt; June 4th, 2004 at 11:05 AM.

IMN logo majestic logo threadwatch logo seochat tools logo