non-interactive password
Bill Moran
wmoran at potentialtech.com
Thu Apr 29 13:01:22 PDT 2004
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
More information about the freebsd-questions
mailing list