Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ping Code Problem
#1
I have the following block of code which i use to Ping multiple addresses

        AN_Sel_State = var4.get()
        if (AN_Sel_State == 1):
            if(s.call(["ping", Output_IP_Address_AN])==0):
                    print("'Ping' Sucessful")
                    IPT_Display_AN = Label(IPT, text=(Output_IP_Address_AN, "Ok"),fg='green', anchor=W)
                    IPT_Display_AN_Window = canvas_IPT.create_window(150, 235, anchor = 'sw', window = IPT_Display_AN)
            else:
                    print("'Ping' NOT Sucessful")
                    IPT_Display_AN = Label(IPT, text=(Output_IP_Address_AN, "Failed"),fg='red', anchor=W)
                    IPT_Display_AN_Window = canvas_IPT.create_window(150, 235, anchor = 'sw', window = IPT_Display_AN)
This works as expected in instances were packet data is received (Succesful) and also works when 'Request timed out' (Not Succesful) however when 'Host Unreachable' it returns the result is successful which is wrong.

I cant seem to work out what my mistake is the return should be ==1 in both instances of 'Request timed out' and 'Host Unreachable'
Reply
#2
Done some more research on this and i am lead to believe that "Host Unreachable" returns as ==0 even though the ping wasn't actually successful (Still dont really understand why this is ?)

If this is the case how do i exclude "Host Unreachable" from displaying successful when it has the same exit status ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need some guidance on a script to ping a list of ip's cubangt 11 10,798 Aug-10-2023, 02:39 PM
Last Post: snippsat
  non-stop ping script kucingkembar 1 2,611 Aug-23-2022, 06:29 AM
Last Post: menator01
  Ping command using python 3.6.5 Martin2998 6 38,053 Apr-19-2021, 06:24 PM
Last Post: blazejwiecha
  Create a program that PING a list of IPs skaailet 7 11,965 Mar-26-2020, 10:46 PM
Last Post: snippsat
  ping with output jacklee26 1 6,735 Nov-28-2019, 01:01 PM
Last Post: Axel_Erfurt
  PING PONG GAME akea 0 6,800 May-08-2019, 04:30 PM
Last Post: akea
  ping and pong run both well sylas 1 4,332 Sep-24-2017, 05:14 PM
Last Post: sylas
  Ping Sweep help The501stOfNoobPy 5 9,609 Jun-26-2017, 10:22 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020