Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Apr 2004 15:59:00 -0400
From:      Bill Moran <wmoran@potentialtech.com>
To:        freebsd-questions@FreeBSD.org
Subject:   Re: non-interactive password
Message-ID:  <40915E84.9040106@potentialtech.com>
In-Reply-To: <20040429193544.GH419@keyslapper.org>
References:  <20040424232033.GA53918@keyslapper.org> <20040424184957.I57098@sotec.home> <20040429193544.GH419@keyslapper.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Louis LeBlanc wrote:
> On 04/24/04 06:52 PM, Mikko Työläjärvi sat at the `puter and typed:
> 
>>On Sat, 24 Apr 2004, Louis LeBlanc wrote:
>>
>>>Hey everyone.  I'm trying to recreate a password script that sets
>>>passwords (as root on the local system only).  The trick is that it
>>>must change the password non-interactively.  I had this working, but
>>>when the system was trashed, the script was lost.
>>>
>>>Can someone refresh my memory on the command format?
>>
>>  echo "$password" | pw usermod "$user" -h0
>>
>>Might do the trick.
> 
> 'fraid not.  It fails quietly, but it fails.
> 
> Thanks anyway.

The man page for pw says that pw needs a file descriptor to set the
password via -h

I'm not 100% sure, but I seem to remember that most shells provide a
sort of "heredoc" support for this.  Such that:

pw usermod "$user" -h <<<END
newpassword
newpassword
END

would work.  Don't quote me on this.  I'm sure of the basic approach,
but I'm not sure of the exact syntax used.  I just had a thought,
though - the version of the adduser script in FreeBSD 5 is written
in sh instead of perl (4.x is in perl) so you should be able to check
that code for a workable syntax.

-- 
Bill Moran
Potential Technologies
http://www.potentialtech.com



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