Skip to content

Commit

Permalink
Add script to show connected users
Browse files Browse the repository at this point in the history
  • Loading branch information
thp committed Jun 24, 2013
1 parent 6514eb5 commit 069b259
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions connected_clients.py
@@ -0,0 +1,22 @@
#!/usr/bin/python
#
# Show connected clients using SSH ("SDK mode")
#
# Author: thp
# Request: http://talk.maemo.org/showpost.php?p=1354336&postcount=905
#

import subprocess

"""
Example output of 'who' on Harmattan:
user pts/0 00:00 Jun 24 09:25:38 192.168.2.14
"""

who = [line.split() for line in subprocess.Popen(['who'],
stdout=subprocess.PIPE).communicate()[0].splitlines()]
print (('%d user%s connected: %s' % (len(who), 's' * (len(who) != 1),
', '.join('%s (%s)' % (x[0], x[-1]) for x in who)))
if who else 'no users connected')

0 comments on commit 069b259

Please sign in to comment.