about summary refs log tree commit diff stats
path: root/bin/connusers.py
diff options
context:
space:
mode:
Diffstat (limited to 'bin/connusers.py')
-rwxr-xr-xbin/connusers.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/connusers.py b/bin/connusers.py
new file mode 100755
index 0000000..a09ae4a
--- /dev/null
+++ b/bin/connusers.py
@@ -0,0 +1,21 @@
+#!/usr/local/bin/python3 -I
+
+from sys import exit
+import subprocess
+
+def checkconns():
+    try:
+        conntable = open("/var/www/htdocs/table.connusers", "w")
+    except:
+        print("Can't access connected user table. Who are you?")
+        exit(0)
+
+    connusers = list(set(subprocess.check_output("/usr/bin/who -q; exit 0", stderr=subprocess.STDOUT,shell=True).decode().splitlines()[0].split()))
+    conntable.write("<ul>\n")
+    for conn in connusers:
+        conntable.write("<li><a href=\"https://"+ conn +".tilde.institute\">"+ conn +"</a></li>\n")
+
+    conntable.write("</ul>\n")
+
+if __name__ == '__main__':
+    checkconns()