#!/bin/sh
USER=newuser
PASS=newpass
mkuser $USER > /dev/null 2>&1
MKUSER_STATUS=$?
case $MKUSER_STATUS
in
0) echo "$USER created successfullly.";;
17) echo "$USER Already exists."
exit 1;;
22) echo "$USER invalid name format."
exit 1;;
86) echo "$USER name too long."
exit 1;;
127) echo "Insufficient securities."
exit 1;;
*) echo "$USER not created."
exit 1;;
esac
echo $PASS > `passwd $USER`
Pardon my syntax, as I'm sure it's incorrect, but you get the gist.
The systems are running 4.2 and 4.3.
--
Thanks,
Jeff
Mkpasswd is used to create DBM files for a system that has such
a large number of users that searching, say, /etc/passwd for a user
entry (which is a fairly common operation) takes too long.
I'd suggest reading this post:
Some people also use expect for this.
Regards,
Nicholas
P.S. The reason your approach won't work is that the passwd command
opens /dev/tty directly, bypassing stdin.
--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html