How do I determine if id is valid login?
2007-12-25 10:49:00
Thank you to everyone who answered. The basic approach requires using
ypmatch (nismatch on NIS+) or greping on /etc/passwd (/etc/shadow if
you are root and use shadow passwords) and piping it to:
awk -F: '{print $2}'
This will return an empty string if the login doesn't exist and it will
return '*' or LK or NP if there is no password for that account.
If you use Perl, there is a function called getpwnam() which will get
the same information.
My thanks to:
Jeff Popp
Roy Rapoport
Charles Gagnon
Edward Grimm
Nicky Ayoub
Walter Moore
Lee Frank
The original request:
>
> I'm writing a script in which I need to determine if a given word is a
> valid login name. It has to be a name which requires a password, e.g.
> lp, uucp and the like would be considered invalid. Is there a way to
> determine this?
>
--
Laurent Duperval, Systems Analyst Grafnetix Systems Inc.
Tel: (514) 861-3389 777, de la Commune Ouest
Fax: (514) 866-6206 Suite 101, Montreal, Qc
Laurent@Grafnetix.COM Canada, H3C 1Y1
URL: http://www.Grafnetix.COM/~laurent
nt
Status: RO
Comments
Got something to say?
You must be logged in to post a comment.

