1752578 Members
4999 Online
108788 Solutions
New Discussion юеВ

Re: Scripting Question

 
Ranjith_5
Honored Contributor

Scripting Question

Hi Experts,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=837084

Pls see the above thread raised by me. I still awaiting for a complete solution for my proble. Its only partially solved.

Regards,
Syam
3 REPLIES 3
Peter Godron
Honored Contributor

Re: Scripting Question

Syam,
I had another dig around, specifically for trusted system and have found:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=86321
Please read the man pages attached to that thread for modprpw.

If you need further examples, search the groups for "trusted passwd script"

Regards
Robert Salter
Respected Contributor

Re: Scripting Question

Syam,

This is totally unsupported and you'd be trying at your own risk, but;
If you can encrypt the password you want to use, copy it say from a test login then you could amend the following in Peter's script

useradd -c "$username" -g dbuser -m -s /usr/bin/ksh -k /etc/skel -d /home/$logid $logid
# This is the risky part
TMPPW=`find /tcb/files/auth -name $logid`
ed $TMPPW << EOF
/pwd
s/\=.*\:/\=YOURTEMPW\:/
w
q
EOF
passwd -f $logid

echo "Created user $username"
done < user.dat

So basically you're setting TMPPW to be the path to the user's TCB file, then doing an 'ed' on the file to substitute your temporary password in the u_pwd field. The line s/\=.*\:/\=YOURTEMPW\:/ is substituting everything between the = and the : with YOURTEMPW (which is your encrypted password). Then you do a passwd -f to force the user to pick a new password.

Why is it risky, because it's not a supported method, so make sure you backup things first.

Good luck

Robert
Time to smoke and joke
Ranjith_5
Honored Contributor

Re: Scripting Question

Hi ,

Hi I couldn't go through the second post or test that.My problem was already solved.

I modified my script again as follows and it is now able to server my purpose. Thanks for all.

############################################################

#!/usr/bin/sh
groupadd dbuser
rm -f passwords.dat
#read all the data in the file user.dat
while read data
do
#split the fields up
#first field
logid=`echo $data | cut -d' ' -f1`
#second field onwards
username=`echo $data | cut -d' ' -f2-`

useradd -c "$username" -g dbuser -m -s /usr/bin/ksh -k /etc/skel -d /home/db$logid db$logid
/usr/lbin/modprpw -x db$logid >> passwords.dat
echo "Created user $username"
done < user.dat
cat passwords.dat|cut -f2 -d"=">passwords.txt
rm -f passwords.dat

########################################################

The above script stored the initial passwords in a txt file called passwords.txt. I only need to do cat passwords.txt and copy paste to excel.
My Problem is solved.

Closing this thread. Thanks all who replied.

regards,
Syam