How to provide password from command prompt ?
Hello all,
I want to know solaris equivalent for providing password on command only without prompting for it. In Redhat Linux, Code:
echo $PASS | passwd $USER --stdin As per http://forum.java.sun.com/thread.jspa?threadID=5296716, There is no way to do the same on Solaris. Thanks in advance, |
Yes, the usual way to do it is by using an expect script. You'll have to install expect as it isn't part of Solaris though.
Alternatively, now that Solaris in open sourced, nothing forbids you to build your custom patched version of passwd http://src.opensolaris.org/source/xr...asswd/passwd.c and add the feature by calling a custom getpassphrase call. |
Thanks for the update.
I am to learn much before updating current passwd command :) so, definately not a good solution for right now. Right now, I am already using expect script for achieving the same. But it is much slower & there are some problem with time synchronization also. As an alternative, I found following perl script. Code:
#!/usr/bin/perl |
That perl script won't work. The module doesn't handle /etc/shadow.
Perhaps the following one will do better. Anyway, directly accessing the shadow file is a bad practice. http://search.cpan.org/~strzelec/Pas...Passwd/Unix.pm |
Quote:
|
jlliagre,
Thanks for your reply. I tried that one on linux machine and it worked. I am in process of installing solaris 10 in VMware and check the same. Also, I agreed with your comment for working with shadow file, But I want to sync passwords between multiple servers using script only. In my environment it is not possible to implement NIS/LDAP. I am replying to vikas with example script. Please update if anything is wrong. vikas027, Sample Shell Script: Code:
#!/bin/bash Code:
#!/usr/bin/perl -w You can enhance it with no. of users ( using for loop ) and error checking. Please try it at your end and update. |
All times are GMT -5. The time now is 06:06 PM. |