Thread: Net : :

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

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    10

    Net : :


    In perl they use
    use Net::Ping;
    In python ????

    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Location
    Belgium
    Posts
    3
    Rep Power
    0

    Re: Net::


    I don't know of something similar in standard python modules. You could try, if you really need it:
    Code:
    output = os.popen('ping x.x.x.x')
    (output being a file object, your command's stdout, actually)
  4. #3
  5. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Try searching this forum or
    google python ping module

    There are a few examples but I agree with sandro - unless you have serious performance issue why not use ping as supplied with your os. It is easy enough to parse the output.

    grim
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    10

    ping servers


    I have a list of hosts and that i want to ping, If successfull put ok for each successfully pinged hosts and no if unsuccessfull ping.

    Thanks
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Well. All you have to do is loop over those addresses and ping them using the 'ping' facility supplied by your OS and the address. For example.

    Code:
    pseudocode
    #!/usr/bin/env python
    
    from os import popen
    
    pings = (...some addesses you wish to ping...)
    
    for ping in pings:
        returned = popen('ping %s' % ping)
        if returned is successful:
            ...
            do thi
            ...
        else:
            ...
            do thi
            ...
    Thats the basic idea, but, im sure it wont take you long to get this working .

    Have fun,

    Mark.
    Last edited by netytan; July 9th, 2004 at 06:08 AM.
    programming language development: www.netytan.com Hula

  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
    You should find my attachment usefull
    Attached Files
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    10
    Thanks for the attached file unfortunately i am unable to use it i think it's linux format, i am not a linux person.

    Thanks
  14. #8
  15. 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
    You can just copy the module to your package dir.. its what i have done in windows and it works
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    57
    Rep Power
    10
    Hi
    Thanks for your help I managed to copy the modules to dir. As i am a beginner to programming and crowling i am going to ask for more help " How do i use these modules to amend my previously posted code.I am confused with Reading books and other tutorial sites. I like to learn with more examples like step by step guide and this is the best site and best pupil to learn.Please do not get irritated with me.
    Thanks

IMN logo majestic logo threadwatch logo seochat tools logo