From 7803adbd089082efe8c55d0a50071bb08844eb6c Mon Sep 17 00:00:00 2001 From: admins Date: Thu, 21 May 2020 01:19:09 -0400 Subject: fixed username truncation properly --- bin/connusers.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/connusers.py b/bin/connusers.py index 998669b..ebdde7f 100755 --- a/bin/connusers.py +++ b/bin/connusers.py @@ -3,6 +3,10 @@ # Lists currently connected users for https://tilde.institute/stats # gbmor +# 'ps' truncates usernames at 8 characters (called by 'showwhoison' to find mosh users) +# so I'm matching the potentially-partial username to a home directory to retrieve +# the full username. + from sys import exit import subprocess @@ -13,20 +17,19 @@ def checkconns(): print("Can't access connected user table. Who are you?") exit(0) - connusers = list(set(subprocess.check_output("/usr/local/bin/showwhoison | sed -n '1!p'; exit 0", stderr=subprocess.STDOUT,shell=True).decode().split("\n"))) + connusers = sorted(list(subprocess.check_output("/usr/local/bin/showwhoison | sed -n '1!p'; exit 0", stderr=subprocess.STDOUT,shell=True).decode().split("\n"))) conntable.write("\n") -- cgit 1.4.1-2-gfad0