Hi Justman,
I only just joined this forum, but have recently completed a similar exercise.
I have a script and a "c" program that was used to migrate users with the encrypted passwords to a P690 running AIX 5.2. With some slight modification the following should work.
Here is the code for pass.c
===============snip================
#include <stdio.h>
#include <pwd.h>
struct passwd *getpwnam();
main(int argc, char **argv)
{
char salt[3], pass[20], cpass[20];
strcpy(salt,"yM");
strcpy(pass,argv[1]);
strcpy(cpass,crypt(pass,salt));
puts(cpass);
}
================snip===============
Here is one way of using the password stuff.
================snip===============
#!/usr/bin/ksh
#############################################################################
#
# adduser.ksh #
# Description: Adds new users to the system group and sets up initial
# password.
#
# Usage: adduser.ksh < input_file
# where input_file has the format:-
# username userid groupid firstname lastname
#
# Co-Reqs: pass (generate encrypted password)
# gettime (returns seconds since epoch)
#
#############################################################################
#############################################################################
#
# must have root access to run this
#
#############################################################################
if [[ ${LOGNAME} != 'root' ]]
then
print "You must be root to run this"
exit 1;
fi
#############################################################################
#
# define location of binaries
#
#############################################################################
BINDIR=/home/davem/bin
#############################################################################
#
# Make a copy of the user security files to regress the changes made by
# this script all that is required is to copy the files back from the .orig
# versions.
#
#############################################################################
cp /etc/passwd /etc/passwd.orig
cp /etc/security/passwd /etc/security/passwd.orig
cp /etc/group /etc/group.orig
#############################################################################
#
# Start processing the users to be created, echo each to the screen.
#
#############################################################################
read user id group fullname
while [ "$user" != "" ];do
print "User: $user\t\tid: $id\t\tGroup: $group\t\tName: $fullname"
mkuser id=$id pgrp=$group groups=$group,staff,system gecos="$fullname" $user
cat /etc/passwd | sed "/^$user:/s/:\*:/:\!:/" > /etc/passwd.new
mv /etc/passwd.new /etc/passwd
if [ `cat /etc/security/passwd | grep -c "^$user:"` != "1" ];then
print "\n$user:" >> /etc/security/passwd
print "\tpassword = "`$BINDIR/pass CH4ng3me` >> /etc/security/passwd
print "\tlastupdate = "`$BINDIR/gettime` >> /etc/security/passwd
print "\tflags = ADMCHG" >> /etc/security/passwd
fi
read user id group fullname
done
chown root /etc/passwd
chgrp security /etc/passwd
chmod 664 /etc/passwd
exit 0;
==================snip====================
With a little modification it should be possible to do what you require with the pass program.
Rgds
Dave