stelnet - # Assignment 2, CSCI 4211 # Ben Sprague, 3296712...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 # Assignment 2, CSCI 4211 # Ben Sprague, 3296712 # Telnet Server #!/soft/python-2.4-bin/python import os, sys, time, socket, threading, commands, string, re def main(): port = int(sys.argv[1]) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) #socket level options sock.bind( ('', port) ) sock.listen(20) print "Welcome to the Server side!" correct = "alan turning 1912\r\n" while 1: try: client, addr = sock.accept() flo = client.makefile('r', 0) message = "Who disturbs my slumber?\n" client.sendall(message) try: password = flo.readline() newline = flo.readline() if newline == "\r\n":#Check first for the second newline if correct == password: #Then check if the password is correct client.sendall("Command me!\n") dostuff = threading.Thread(target = exe, name = 'commands', args=[client]) dostuff.start() else: time.sleep(5) client.sendall("I'm going back to sleep") client.close() except (KeyboardInterrupt, SystemExit):
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/09/2008 for the course CSCI 4211 taught by Professor Sturtivant during the Spring '08 term at Minnesota.

Page1 / 3

stelnet - # Assignment 2, CSCI 4211 # Ben Sprague, 3296712...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online