First commit

main
clt 3 years ago
parent 47f724600f
commit 4bcf772212

@ -1,2 +0,0 @@
# ping_plong

@ -0,0 +1,4 @@
google.com
gt.se
127.0.0.1
googoogogogllglel.com

@ -0,0 +1,32 @@
import subprocess
import platform
print ("PING SCANNER")
#Sätt parameter n om Linux och c om Windows
param = '-n' if platform.system().lower()=='windows' else '-c'
#Ping function
def ping(host):
command = ["ping", param, "1", host]
return subprocess.call(command, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT) == 0
#Pinga enskild host
host = "google.com"
if ping(host):
print("Ping successfull!")
else:
print("Ping unsuccessfull")
#En lista för hostar som ska pingas
host_list = ["google.com", "gt.se", "amazon.com"]
#Loop som pingar varje host i listan
for host in host_list:
print(host)
ping(host)
if ping(host):
print("Ping successfull!")
else:
print("Ping unsuccessfull")
Loading…
Cancel
Save