From 33cfec71405831fdb70bed16aa08ad7222e45b5f Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Thu, 3 Jan 2013 22:34:20 -0800 Subject: pinyadmin: new lsusers command --- pinyadmin/bin/lsusers | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 pinyadmin/bin/lsusers (limited to 'pinyadmin/bin') diff --git a/pinyadmin/bin/lsusers b/pinyadmin/bin/lsusers new file mode 100755 index 0000000..8bccd1c --- /dev/null +++ b/pinyadmin/bin/lsusers @@ -0,0 +1,39 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Getopt::Long::Descriptive; + +my @users = (); +my @pwent = (); + +my ($opt, $usage) = describe_options( + '%c %o', + [ "name|n", "sort by name"], + [ "date|d", "sort by date"], + [ "reverse|r", "reverse sorting"], + [ 'help', "print usage message and exit" ], +); + +if ( $opt->help ) { + print($usage->text); + exit; +}; + +while( @pwent = getpwent()) { + if( $pwent[2] >= 1000 && $pwent[2] < 65534 ) { + push( @users, "$pwent[0]\n" ); + }; +}; + +# sort by date kinda done by default +# maybe sort by time since last password change in /etc/shadow? + +if ( $opt->name ) { + @users = sort( @users ); +}; + +if ( $opt->reverse ) { + @users = reverse( @users ); +}; + +print @users; -- cgit v1.2.3