Anidil Rajendran wrote:
>
> Hi Perl Gurus,
Hello,
> This is a newbie question ofcourse. Since it is not working for me I am asking here.
> I am trying to skip UID above 60000.
The only UID that should be above 60000 is the user "nobody" whose UID
is 65534.
> $passwd = "/etc/passwd";
> $skip = 60000;
> open(PW,$passwd) or die "Can't open $passwd:$!\n";
> while (<PW>){
> @fields = split(/:/);
> next if $fields[2] > $skip;
> $highestuid = ($highestuid < $fields[2]) ? $fields[2] : $highestuid;
> }
> close(PW);
> print "The next available UID is " . ++$highestuid . "\n";
>
> Thanks for any suggestion.
I would probably do it this way:
#!/usr/bin/perl -w
use strict;
my $skip = 60_000;
my $highestuid = -1;
while ( my( undef, undef, $uid ) = getpwent ) {
$highestuid = $uid if $highestuid < $uid and $uid < $skip;
}
print 'The next available UID is ', ++$highestuid, "\n";
__END__
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]