3
# users: print the number of remote users on the machine
4
# Copyright (C) 2009 Raphaël Pinson.
5
# Copyright (C) 2009 Canonical Ltd.
7
# Authors: Raphaël Pinson <raphink@ubuntu.com>
8
# Dustin Kirkland <kirkland@canonical.com>
10
# This program is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU General Public License as published by
12
# the Free Software Foundation, version 3 of the License.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
color 2>/dev/null || color() { true; }
26
if [ "$1" = "--detail" ]; then
27
ps -ef | grep "sshd;.*@" | grep -v grep
31
# Note: we'd like to use pgrep -c, however, this isn't available in
32
# busybox and some distro's pgrep (and it doesn't exit non-zero).
33
count=`pgrep -f "sshd:.*@" | wc -l` || exit 0
34
[ $count -gt 0 ] && printf "$(color b w r)%d$(color -)$(color w r)#$(color -) " $count