redes:notas:python
Diferencias
Muestra las diferencias entre dos versiones de la página.
Próxima revisión | Revisión previa | ||
redes:notas:python [2018/12/27 21:15] – creado cayu | redes:notas:python [Fecha desconocida] (actual) – borrado - editor externo (Fecha desconocida) 127.0.0.1 | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
- | ====== Scripts simples en python ====== | ||
- | <code python> | ||
- | import socket, subprocess, | ||
- | from datetime import datetime | ||
- | subprocess.call(' | ||
- | rmip = raw_input(" | ||
- | r1 = int(raw_input(" | ||
- | r2 = int (raw_input(" | ||
- | print " | ||
- | print "\n Mohit' | ||
- | print " | ||
- | t1=datetime.now() | ||
- | try: | ||
- | for port in range(r1, | ||
- | sock= socket.socket(socket.AF_INET, | ||
- | socket.setdefaulttimeout(1) | ||
- | result = sock.connect_ex((rmip, | ||
- | if result==0: | ||
- | print "Port Open: | ||
- | #print desc[port] | ||
- | sock.close() | ||
- | except KeyboardInterrupt: | ||
- | print "You stop this " | ||
- | sys.exit() | ||
- | except socket.gaierror: | ||
- | print " | ||
- | sys.exit() | ||
- | except socket.error: | ||
- | print "could not connect to server" | ||
- | sys.exit() | ||
- | t2=datetime.now() | ||
- | total=t2-t1 | ||
- | print " | ||
- | </ | ||