Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using mkpasswd in a script non-interactively

1 view
Skip to first unread message

Jeff Rancier

unread,
Feb 25, 2003, 6:24:55 PM2/25/03
to
Is there anyway to create and set a password for new user created by
the mkuser command? I looked at the documentation for mkpasswd, but I
don't think that's what I want. My installation script is run
remotely in a store chain, and one of the customers requirements is
the script be non-interactive. I guess I'd like to do something like:

#!/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

Nicholas Dronen

unread,
Feb 25, 2003, 8:12:58 PM2/25/03
to
Jeff Rancier <jeff.r...@softechnics.com> wrote:
JR> Is there anyway to create and set a password for new user created by
JR> the mkuser command? I looked at the documentation for mkpasswd, but I
JR> don't think that's what I want. My installation script is run
JR> remotely in a store chain, and one of the customers requirements is
JR> the script be non-interactive. I guess I'd like to do something like:

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:

http://groups.google.com/groups?q=comp.unix.aix+set+password+script&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mcuddy.674351554%40rutabaga&rnum=9

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

0 new messages