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 1,687 Aug-10-2023, 02:39 PM
Last Post: snippsat
  non-stop ping script kucingkembar 1 1,321 Aug-23-2022, 06:29 AM
Last Post: menator01
  Win32\ping.exe windows pops up -very annoying... tester_V 9 3,126 Aug-12-2021, 06:54 AM
Last Post: tester_V
  Looking for discord bot to make loop ping for address ip tinkode 0 1,789 Jul-26-2021, 03:51 PM
Last Post: tinkode
  Ping command using python 3.6.5 Martin2998 6 17,251 Apr-19-2021, 06:24 PM
Last Post: blazejwiecha
  GPIO high if network IP has good ping duckredbeard 3 2,281 Oct-12-2020, 10:41 PM
Last Post: bowlofred
  Create a program that PING a list of IPs skaailet 7 6,123 Mar-26-2020, 10:46 PM
Last Post: snippsat
  ping with output jacklee26 1 4,851 Nov-28-2019, 01:01 PM
Last Post: Axel_Erfurt
  PING PONG GAME akea 0 5,643 May-08-2019, 04:30 PM
Last Post: akea
  ping and pong run both well sylas 1 3,132 Sep-24-2017, 05:14 PM
Last Post: sylas

Forum Jump:

User Panel Messages

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