Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auotmated password change and force new pass

Status
Not open for further replies.

art15t

MIS
Apr 8, 2002
77
GB
I have a -p[assword] option to a script which creates user accounts in non-interactive mode. If this option is passed then the script will generate a random password (saving the info to a 400 perm file owned by root) and automatically set the password.

Is there a way to pass the randomly generated password into the stdin of the passwd command? I tried the usual &quot;<<EOF&quot; and echoing the input via a pipe but can't get it to work.

Any ideas?
 
Just to clarify what I'm looking for is something similar to the following but which actually works :)

set_pass() {

PASSWD=&quot;`echo $LOGIN|cut -c1-3``echo $RANDOM`&quot;
/usr/bin/passwd $LOGIN << EOF
echo $PASSWD
echo $PASSWD
EOF
}

if [ $POPT -eq 1 ]
then
set_pass
if [ $? -eq 0 ]
then
echo &quot;$LOGIN:$PASSWD&quot; >>$FILE
fi
fi
 
Thanks for that MARSD!

I compiled and installed tcl/tk/expect. Now I'm able to create accounts on mass(courtesy of Don Libes mkpasswd) unattended. Not an every day thing I grant you but comes in bloody handy when the need arises.

ART
 
Expect is showing it's age,(First extension written for
tcl: 90-91 I think), but it is still incredibly useful for a lot of things.
Scriptable interaction with interactive programs still
causes a majority of the hurdles that people run into
when dealing with automation.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top