import os, os.path, sys, commands, string, re if sys.platform == "win32": print "unique : debug" print "name : debugName" print "tty : debugTTY" print "when : debugWhen" print "idle : debugIdle" print "pid : debugPID" print "from : debugFrom" print "" else: output = commands.getstatusoutput("who -u") if output[0] == 0: lineByLine = string.split(output[1], "\n") for line in lineByLine: clean = string.split(string.strip(re.sub("\s+", " ", line)), " ") if len(clean) > 6: print "unique : " + string.join(clean[0:2], ".") print "name : " + clean[0] print "tty : " + clean[1] fromIndex = len(clean)-1 print "logontime : " + string.join(clean[2:fromIndex-2], " ") print "idle : " + clean[fromIndex-2] print "pid : " + clean[fromIndex-1] print "location : " + clean[fromIndex] print ""