Re: sys.exc_type etc

ALAN BARNES (asbarnes@mtu.edu)
Sun, 22 Mar 92 16:15:11 EST

Hi, this is my first post to the list so bear with me....I am trying to write
a simple finger server just to see if I can do it. I basically have it working
except for a few things. First off, it sends the passwd field. I plan on
fixing this. Another thing is that it is formatted terribly right now. It just
spits the information out with no indication as to what it is. And my real
problem is this: I can connect to the port I am running this on. I type in a
user name and it gives me the information for that user. And then it closes
the connection. But what I want to do is only kill the connection of the
person who called. I can't seem to figure out how to do this. So, my little
finger program will only finger one person then quit. Any suggestions will be
appreciated. Thanks...I am including a copy of my program...

#this is a finger program I am writing in the python language
#it isn't working so hot.....
#

import string
from time import sleep
import sys
from socket import *
from pwd import getpwnam

PORT = 45678
SIZE = 10

def main(): #recognize this?
if len(sys.argv) > 1:
PORT = int(eval(sys.argv[1]))
else:
PORT = 45678
s = socket(AF_INET, SOCK_STREAM)
s.bind('', PORT)
s.listen(3)
conn, (remotehost, remoteport) = s.accept()
print 'Connection from ', remotehost, ' established.'
data = conn.recv(SIZE)
print len(data)
data = data[:-2]
field = getpwnam(data)
for x in range(len(field)):
conn.send(string.zfill(field[x], 1))
conn.send('\n')
conn.send('\n')
conn.close()

main()