1 # shell 2 last | cut -d ' ' -f 1 | sort -u
1 #python 2 from subprocess import Popen,PIPE 3 4 p1 = Popen('last',shell=True,stdout=PIPE) 5 6 p2 = Popen('cut -d ' ' -f 1,shell=True,stdin=p1.stdout,stdout=PIPE) 7 8 p3 = Popen('sort -u',shell=True,stdin=p2.stdout,stdout=PIPE) 9 10 >>print p3.stdout.read()