how do I (non-interactively) change a users password in a script ?

Bill Campbell freebsd at
Mon Jan 16 22:13:01 PST 2006

On Tue, Jan 17, 2006, user wrote:
>/bin/sh script.
>Need to change a users password within the script based on a file of
>user/pass I am feeding the script.

See ``man pw'', in particular the ``-h fd'' option.

>Except the passwd command does not seem to be able to take a password as
>an argument - I don't think that the passwd command can run

You can also use expect which is designed for just this sort of thing.

INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
URL:  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

``Ah, you know the type.  They like to blame it all on the Jews or the
Blacks, 'cause if they couldn't, they'd have to wake up to the fact that
life's one big, scary, glorious, complex and ultimately unfathomable
crapshoot -- and the only reason THEY can't seem to keep up is they're a
bunch of misfits and losers.''
        -- A analysis of Neo-Nazis, from "The Badger" comic

More information about the freebsd-questions mailing list