From 8c1a40d00ca69f2194a9f7c4cf4e884a2d225d3d Mon Sep 17 00:00:00 2001 From: hc Date: Sat, 1 Feb 2025 11:07:07 +0800 Subject: formatednicely --- client_ls.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) mode change 100644 => 100755 client_ls.py (limited to 'client_ls.py') diff --git a/client_ls.py b/client_ls.py old mode 100644 new mode 100755 index 6aa3a7e..fdcfc78 --- a/client_ls.py +++ b/client_ls.py @@ -1,4 +1,4 @@ - +#!/usr/bin/env python3 #lists client information import fcntl @@ -12,10 +12,14 @@ def read_data(): # Get shared lock for reading fcntl.flock(f.fileno(), fcntl.LOCK_SH) try: - return json.load(f) + data = json.load(f) + for pid, info in data.items(): + print(info) + return {} finally: fcntl.flock(f.fileno(), fcntl.LOCK_UN) except (FileNotFoundError, ValueError): + print("file /tmp/ssh_sessions.json not found") return {} -print(read_data()) +read_data() -- cgit v1.2.3-70-g09d2