Created
October 16, 2019 13:06
-
-
Save kurotych/2092b787c031996ace9d4aa3c7393711 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
import time | |
HOST = '10.0.0.1' | |
PORT = 143 | |
while(1): | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.connect((HOST, PORT)) | |
s.send(b'. login x y\n') | |
data = s.recv(4096) | |
if b"* OK [CAPABILITY" in data: | |
print('.', end = '', flush = True) | |
continue | |
elif b"Service unavailable" in data: | |
print('Service unavailable') | |
break | |
else: | |
print('Non expected server response: ', str(data)) | |
break | |
s.close() # close() will be calling automatically. It for visibility |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment