Operating System - HP-UX
1748194 Members
4496 Online
108759 Solutions
New Discussion юеВ

Changing user password in HP-UX programmatically

 
SOLVED
Go to solution
Ahmed Atef
Occasional Advisor

Changing user password in HP-UX programmatically

Is there anyway -using shell scripting or C program- to change the user password programmatically. "I thing it can be done using TCL / Expect" but is there any simpler way ???

Thank You
Ahmed
2 REPLIES 2
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Changing user password in HP-UX programmatically

Yes, man putpwent(3C) (non trusted systems), putprent(3C) (trusted systems), and yppasswd(3N) for NIS environments. You will also need to look at getpass and crypt(3). This is one of the few cases where NIS is probably the easist method. But the process is rather simple in c.

One thing to remember - while doing development
make sure that 1) you have copied a good version of /etc/passwd to a safe place 2) you are logged on as root in at least one other place so that you can replace your corrupt passwd file; and 3) after modifying the passwd file with your code run pwck to make sure all is well.

This should get you started, Clay.
If it ain't broke, I can fix that.
Theo Wawers
Occasional Contributor

Re: Changing user password in HP-UX programmatically

Hi,

try using the expect tool. You can download and read about it at http://expect.nist.gov
It's really useful for a lot of things.

Cheers,
Theo