Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-26-2012, 02:10 PM
|
#1
|
|
Member
Registered: Nov 2011
Posts: 53
Rep: 
|
set passwords in a script in solaris 9 and return
I have a script that adds a user to the solaris 9 system
I also have a random password generator so I can pass the password to the command but someone needs to hit return twice to set it, I want the script to set it for me so I don't have to hit return. As it is now after I add the user I set the password manually I don't want to do that I want the script to do that for me, How do I make this work
|
|
|
|
10-26-2012, 03:14 PM
|
#2
|
|
Member
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 204
Rep:
|
What do you want the script to do?
Many cli programs that require a password have the option of passing the password as a parameter. For example useradd takes the -p flag followed by a string to add the password. If this is used you will not need to press return twice when the user account is set up.
HTH
|
|
|
|
10-26-2012, 03:14 PM
|
#3
|
|
Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,644
|
I haven't done it on Solaris 9 but generally whenever you have an interactive program that waits for response to prompts the best thing to use is "expect".
I found this thread about expect for Solaris 9.
http://compgroups.net/comp.unix.sola...all-sol/333544
|
|
|
|
10-30-2012, 02:33 PM
|
#4
|
|
Member
Registered: Nov 2011
Posts: 53
Original Poster
Rep: 
|
send variable to expect
I have a user add script to add a user to Solaris 9 it does everything except set the password, I have a password generator in my script I want to set the generator to a variable and pass the variable to expect so I can set the password when adding the user.
|
|
|
|
10-31-2012, 09:48 AM
|
#5
|
|
Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,644
|
Within expect you can use command line arguments passed in so for example using first argument from command line (e.g. same thing as $1 in a shell script):
set newpw [lrange $argv 0 0]
whaterver...
send $newpw
|
|
|
|
11-02-2012, 11:24 AM
|
#6
|
|
Member
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,OpenBSD
Posts: 498
Rep: 
|
You could create the hash yourself and then append a line (all 7 fields) to /etc/passwd . After all accounts are added run pwconv . If doing this I'd set the "must change at next login" option in the hash to force a change to the new and better hashes available in Solaris 9.
|
|
|
|
11-05-2012, 09:58 AM
|
#7
|
|
Member
Registered: Nov 2011
Posts: 53
Original Poster
Rep: 
|
from password generator to expect for Solaris
what I want to do is this I have a password generator as seen below which is in my script. this works for linux because linux has the "-p" option to pass the password too during the run of the useradd command, but Solaris doesn't as seen below for linux which is actually 2 stages
Code:
password=`</dev/urandom tr -dc A-Za-z0-9 | head -c8`
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) # passing the password entered
"useradd -u $uid -p $pass -c "$comment $commentstatic" -d $homedir -s $shell $username"
then take the "password" variable and send that to expect so I don't have to enter it manually.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:56 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|