program to Ping ip addresses

Nick Stinemates nick at stinemates.org
Fri Apr 18 15:01:02 EDT 2008


On Tue, Apr 15, 2008 at 07:24:05AM -0700, shawn s wrote:
> Hi 
> 
> I am trying to modify a small program i found off the internet as follows... I can get the 'tracert' to work and it gives me all the info back. However, when i replace the tracert with 'ping',  the commamd prompt shows 'testing' and the script freezes... any suggestions as why it is doing that.
> 
> import os
> import sys 
> xyz = 1
> 
> while xyz==1:
>     ip = raw_input("command >> ")
>     zx = open("log.txt", "a")
>     
>     if ip.lower()=="exit":
>         ask = raw_input("Are you sure you want to exit? (Y\\N) ")
>         
>         if ask.lower()=="y":
>             sys.exit()
>         elif ask.lower()=="n":
>             print("That's what I thought.")
>         else:
>             print("Wrong choice. Retard.")
>             
>     elif ip.lower()=="range":
>                 stin = raw_input("Enter function: ")
>         sec = raw_input("Enter the first 3 sections: ")
>         b = raw_input("Enter beginning number: ")
>         intb=int(b)
>         e = int(raw_input("Enter ending number: "))
>         
>         while intb<=e:
>             print (stin + ' ' + sec + '.' + b )
>             z = os.system(stin + ' ' + sec + '.' + b )
>             print z
>             
>             if z==0:
>                 print(""+str(sec)+"."+str(b)+" is online.")
>                 zx.write(""+str(sec)+"."+str(b)+" is online.\n")
>             elif z==1:
>                 print("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.")
>                 zx.write("Either "+str(sec)+"."+str(b)+" is offline, or ping request has been blocked.\n")
> 
>             intb = intb + 1
>             b=str(intb)
> 
>     else:
>         
>         print("Wrong choice. Retard.")
> 

I love that you call the users of your app retards :) That rocks!

ping runs forever. tracert doesnt.
try:
> ping -w 5


-- 
Nick Stinemates (nick at stinemates.org)
http://nick.stinemates.org



More information about the Python-list mailing list