Operating System - HP-UX
1834125 Members
2322 Online
110064 Solutions
New Discussion

Re: how to change passwd by script

 
SOLVED
Go to solution
dongming
Frequent Advisor

how to change passwd by script

Hello
i need to write a script to change passwd for a user on all servers. can i use passwd << EOF to change passwd by scripts.
thanks
8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: how to change passwd by script

Nope, that won't work.

See this thread for more discussion on this subject:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=942471
Mel Burslan
Honored Contributor

Re: how to change passwd by script

if you have a burning desire to scriptize it, you need help from something like expect. You can find expect at:

http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.43/

in depot format for 11.11 and 11.23 versions as well as its source code for you to compile.

Then you need to peek at the man pages to figure out how to use it for your purpose.
________________________________
UNIX because I majored in cryptology...
Alan Meyer_4
Respected Contributor

Re: how to change passwd by script

I did this once and am trying to remember how... I think I had to do it in perl and had to get a special module installed to handle it... It'll take me a while to research it though...
" I may not be certified, but I am certifiable... "
Alan Meyer_4
Respected Contributor

Re: how to change passwd by script

I think it was Unix::PasswdFile

CPAN link is here
http://search.cpan.org/~ssnodgra/Unix-ConfigFile-0.06/PasswdFile.pm
" I may not be certified, but I am certifiable... "
Devesh Pant_1
Esteemed Contributor

Re: how to change passwd by script

dongming,
expect is the way to go. You can download expect and try various expect scripting ideas

thanks
devesh
Amit Agarwal_1
Trusted Contributor
Solution

Re: how to change passwd by script

There is a restricted command
/usr/sam/lbin/usermod.sam that can achieve this. The option for passwd change is -p, but i don't remember the exact syntax.

I don't have a HP-UX box right now to verify it, but from my memory it should be
usermod.sam -p

Please note that this is internal command and no official support can be claimed.
dongming
Frequent Advisor

Re: how to change passwd by script

thanks a lot for help.
i just check usermod.sam it is link to usermod which is used for change uid gid hoe dir and so on , not for passwd.
i remember we can just copy and paste on the passwd field in passwd file.
Mel Burslan
Honored Contributor

Re: how to change passwd by script

usermod.sam -p works for changing encrypted password field. The new password provided on the command line can not be clear text password. It needs to be encrypted first.
________________________________
UNIX because I majored in cryptology...