import posix
import string
uid = `posix.getuid()`
passwd = open('/etc/passwd')
for line in passwd.readlines():
  rec = string.splitfields(line, ':')
  if rec[2] == uid:
    print 'hello', rec[0],
    print 'mind if we call you bruce?'
    break
  else:
     print "I can't find you in /etc/passwd"
 :)

Indent it correctly, download posix and give it a try.

Looks like it should work, assuming you have posix there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.