"N. Kofi Amu" wrote:
>
> Thank you Anthony for your response. I appreciated the need to repeat the password
>on the
> terminal or in the GUI. What I need is I have over twenty users to setup and I do
>have
> these users names in a database. All I need is to add their passwords and export
>them as
> Tab Deleminated files into the Linux/Unix user file using the READ command. The only
> thing I need to know is how to assign the PASSWD command in the script. I cannot
>repeat
> the command twice. How do I go about it in the script?
>
> Thanks.
>
> Anthony Huereca wrote:
>
> > It's put in there twice to make sure you typed in your password right. It
> > would be really bad if you accidently mistyped your password when you created
> > it, and had no way of knowing it till you found out you couldn't log in.
> >
> > >On the command line when you type PASSWD username it request for the
> > > password twice. How could I control that in my script. It there another way or
>some
> > > switch that will not let it ask for this the second time?
> > >
> > > Thank in advance and keep up to the good work.
> > >
> > > Kofi Amu
> > > Maru a Pula School
> > > Gaborone
> >
> > --
> > Anthony Huereca
> > http://m3000.1wh.com
> > Computers are not intelligent. They only think they are.
The file /etc/passw contains a db about
the useraccounts= 1 line pro user.
Ex.: kofi:cNgghJeqhh:500:4:Kofi
Amu:/home/kofi:/bin/bash
If shadow is utilised see /etc/shadow.
The standard interface of it:
#include <sys/types.h>
#include <pwd.h>
struct passw *getpwuid (uid_t uid);
struct passw *getpwnam (const char
*name);
(see header files for more dtails)
Example to extract details from db of
passwords attached.
Eric
--
FRANCE (Be careful, my English can hurt
you)
#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
uid_t uid;
gid_t gid;
struct passwd *pw;
uid = getuid();
gid = getgid();
printf("User is %s\n", getlogin());
printf("User IDs: uid=%d, gid=%d\n", uid, gid);
pw = getpwuid(uid);
printf("UID passwd entry:\n name=%s, uid=%d, gid=%d, home=%s, shell=%s\n",
pw->pw_name, pw->pw_uid, pw->pw_gid, pw->pw_dir, pw->pw_shell);
pw = getpwnam("root");
printf("root passwd entry:\n");
printf("name=%s, uid=%d, gid=%d, home=%s, shell=%s\n",
pw->pw_name, pw->pw_uid, pw->pw_gid, pw->pw_dir, pw->pw_shell);
exit(0);
}