Skip to content

Instantly share code, notes, and snippets.

@kurotych
Created October 16, 2019 13:06
Show Gist options
  • Save kurotych/2092b787c031996ace9d4aa3c7393711 to your computer and use it in GitHub Desktop.
Save kurotych/2092b787c031996ace9d4aa3c7393711 to your computer and use it in GitHub Desktop.
#!/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