Skip site navigation (1)Skip section navigation (2)
Date:      22 Jan 2002 01:28:40 -0500
From:      Joe Clarke <marcus@marcuscom.com>
To:        Joe & Fhe Barbish <barbish@a1poweruser.com>
Cc:        FBSD Questions <questions@FreeBSD.ORG>
Subject:   Re: pw in script to create new user.
Message-ID:  <1011680920.27463.10.camel@shumai.marcuscom.com>
In-Reply-To: <LPBBIGIAAKKEOEJOLEGOKEFHCNAA.barbish@a1poweruser.com>
References:  <LPBBIGIAAKKEOEJOLEGOKEFHCNAA.barbish@a1poweruser.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1011680920.27463.10.camel>