Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

executing UNIX passwd command through Java

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way to execute UNIX's passwd command through Java? When I execute this command is UNIX shell it's interactive, so I don't see a way of simulating <enter> key through Java code. Is there another way?
thanks,
Alex
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead u can make a C EXE and run that from java prog...
use Process class for that and Process.exe() for that...
i've nt done this but i believe its possible in C.
regards
maulin
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, I know it's possible to use C module for this, but I wanted to know if it was possible to do the same thing straight from java.
 
Dave Van Even
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this should work
echo <password> | passwd <username>

where
<password> = your desired password
<username> = your username

You can easely execute that with
Runtime.getRuntime().exec("echo <password> | passwd <username>");

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic