-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathping.py
47 lines (31 loc) · 1.1 KB
/
ping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os, time
class testes:
def pingar(self, pacotes, host):
self.pacotes = pacotes
self.host = host
try:
return os.system(f'ping -c {pacotes} {host}')
except:
return 'ERRO'
def pingar_simples(self, host):
self.host = host
try:
return os.system(f'ping {host}')
except:
return 'ERRO'
def pingar_txt(self, filename, pacotes):
self.pacotes = pacotes
self.filename = filename
with open(filename, 'r') as file:
dump = file.read()
dump = dump.splitlines()
for ip in dump:
return os.system(f'ping -c {pacotes} {ip}')
time.sleep(1)
if __name__ == "__main__":
app = testes()
pacotes = int(input('Entre com o numero de pacotes para pingar: '))
host = input('Entre com o host ou ip para pingar: ')
app.pingar(pacotes, host)
#app.pingar_simples(host)
# app.pingar_txt('hosts.txt', pacotes)