my ( $name, $passwd, $uid, $gid, $qutoa, $comment, $gcos, $dir, $shell
+, $expire ) = getpwent;
and, if the user doesn't exist, it returns a "single meaningless true value". So I'd suggest calling getpwent, and then checking one of the values after the first one to see if it's defined or not. If not, the user ought not exist. So something like:
my ( $name, $passwd, $uid, $gid, $qutoa, $comment, $gcos, $dir, $shell
+, $expire ) = getpwent($account);
# An account *must* have a UID, so let's check that
if ( defined $uid ) {
print "User $account uid=$uid. OK to delete user!\n";
}
else {
print "User $account does not exist...\n";
}
...roboticus
When your only tool is a hammer, all problems look like your thumb. |