diff --git a/modulo_os/__pycache__/utilities.cpython-311.pyc b/modulo_os/__pycache__/utilities.cpython-311.pyc new file mode 100644 index 0000000..16dd7f5 Binary files /dev/null and b/modulo_os/__pycache__/utilities.cpython-311.pyc differ diff --git a/modulo_os/ping.py b/modulo_os/ping.py new file mode 100644 index 0000000..bf6af29 --- /dev/null +++ b/modulo_os/ping.py @@ -0,0 +1,18 @@ +import os +import utilities +import sys + +endereco = input("Digite um endereço IP: ") + +if not utilities.validar_ip(endereco): + print ("O endereço IP é inválido.") + sys.exit(0) + +comando = f"ping {endereco}" + +resultado = os.system(comando) + +if not resultado: + print("O endereço existe") +else: + print("O endereço não existe") \ No newline at end of file diff --git a/modulo_os/testes.py b/modulo_os/testes.py new file mode 100644 index 0000000..39810e7 --- /dev/null +++ b/modulo_os/testes.py @@ -0,0 +1,8 @@ +import os +print (os.name) + +print (os. getcwd()) + +print(os.environ) + +print(os.path) \ No newline at end of file diff --git a/modulo_os/utilities.py b/modulo_os/utilities.py new file mode 100644 index 0000000..e975ab1 --- /dev/null +++ b/modulo_os/utilities.py @@ -0,0 +1,8 @@ +def validar_ip (ip : str) -> bool: + octetos = ip.split(".") + if len(octetos) != 4: + return False + for octeto in octetos : + if int (octeto) <0 or int(octeto) > 255: + return False + return True