From owner-freebsd-questions Mon Jan 21 22:28:34 2002 Delivered-To: freebsd-questions@freebsd.org Received: from creme-brulee.marcuscom.com (rdu57-28-046.nc.rr.com [66.57.28.46]) by hub.freebsd.org (Postfix) with ESMTP id 7DF7937B402 for ; Mon, 21 Jan 2002 22:28:29 -0800 (PST) Received: from shumai.marcuscom.com (marcus@shumai.marcuscom.com [192.168.1.4]) by creme-brulee.marcuscom.com (8.11.6/8.11.6) with ESMTP id g0M6RRZ65809; Tue, 22 Jan 2002 01:27:27 -0500 (EST) (envelope-from marcus@marcuscom.com) Subject: Re: pw in script to create new user. From: Joe Clarke To: Joe & Fhe Barbish Cc: FBSD Questions In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Mailer: Evolution/1.0.1 Date: 22 Jan 2002 01:28:40 -0500 Message-Id: <1011680920.27463.10.camel@shumai.marcuscom.com> Mime-Version: 1.0 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 2002-01-21 at 23:52, Joe & Fhe Barbish wrote: > I have sh script with this in it > Pw adduser tom -m -c bkup manager -o > The /etc/pw.conf has all the defaults, one is to > make the password the same as the userid. > The -o option will take input from keyboard for the > Password but this is a canned script so I need to > Some how pass the password value to the pw command -0 option. > > How can I configure the script to hold the password value > for that userid so when the pw adduser command is executed > the correct password gets used in creating the user? I sent you this email earlier today. I said to use the -h 0 option when scripting pw. > > A example of the script pw command would be great. This is what I use from Perl: # Now, update the password entry. unless(open(PW, "| /usr/sbin/pw usermod $user -h 0")) { carp "Unable to open a pipe to /usr/sbin/pw.\n"; exit 3; } print PW $newPass, "\n"; unless(close PW) { carp "/usr/sbin/pw exited on $?: $!\n"; exit 3; } This of course uses pw in the usermod function, but you can easily modify it to do what you need. This sets $user's password to $newPass. Joe > > Thanks > Joe > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message