"Scott R. Godin" wrote: > > try this for starters (tested) > > #!/usr/bin/perl > require 5.006; > use warnings; > use strict; > > my $usrname = $ARGV[0] || 'daneilson'; > > open(PASSWD, '<', '/etc/passwd') > or die "Unable to open /etc/passwd: $!"; > > #dunno how big it is so let's line-by-line it > my $found = 0; > while (<PASSWD>) > { > chomp; > my @line = split /:/; > if ( (lc($line[0]) eq lc($usrname)) && ($line[3] == 45) ) ^^ ^^ This won't work if a user name has upper case letters, for example I just created these two accounts:
# cat /etc/passwd [snip] roger:x:5001:100:Roger 1 Test:/home/roger:/bin/bash Roger:x:5002:100:Roger 2 Test:/home/Roger:/bin/bash > { > ++$found; > print "Found [$found]:\n\t", join("\n\t", @line), "\n"; > } > } > > if ($found) > { > print "Total records found = [$found]\n"; > } > else > { > print "No records were found that matched\n"; > } > __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]