Change password via perl

macvillage.net

Registered
Does anyone know how to change a password via perl?

I am using a Mac OS X box as a fileserver, and am looking ofr a way to change a password via a remote interface....

I know how to secure it properly... just not how to actually change it.

Anyone know of a script already? or know exactly the commands?
 
I think you might be able to use the niutil shell command to change the password. You might also be able to use the passwd shell command.
 
You can use the 'passwd' command, but you'll need to interact with it. To do that, you'll need perl's Expect module. I don't believe OS X's perl has Expect included, you'll probably have to install it (go to www.cpan.org for help installing Perl modules). To see if you have Expect installed, run the following command from the Terminal:
perl -mExpect

If it hangs waiting for input, hit ctrl-c-- you're good to go. If it spits back a lengthy error message about "could not find Expect.pm...", you'll have to install it.

Read the perldoc on Expect. There should be several examples there.

Paul M.
 
Back
Top