Changinging password for linux users
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   kumar_gopi
Posted On:   Monday, September 3, 2001 11:40 PM

How can i change the password for the linux user using java programming.I tried with Runtime.getRuntime.exec("passwd") and with outputstreams of this process,but failed to change.
Can anybody help?

Re: Changinging password for linux users

Posted By:   Thomas_Mathis  
Posted On:   Tuesday, September 4, 2001 01:23 AM

Create the script chgpasswd on your linux machine and put it in the system path.



#!/bin/sh

chpasswd < $1



With your java program you have to create a temp file with the following entries:



username1:passwordForUser1

username2:passwordForUser2



Now you can start your exec command:


String action = "chgpasswd " + tempFilePath;

Process process = runtime.exec( action );

About | Sitemap | Contact