LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris and OpenSolaris.
General Sun, SunOS and Sparc related questions also go here.

Notices

Reply
 
Search this Thread
Old 10-26-2012, 02:10 PM   #1
slufoot80
Member
 
Registered: Nov 2011
Posts: 61

Rep: Reputation: Disabled
Smile 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
 
Old 10-26-2012, 03:14 PM   #2
archShade
Member
 
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
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
 
Old 10-26-2012, 03:14 PM   #3
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,954
Blog Entries: 5

Rep: Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755
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
 
Old 10-30-2012, 02:33 PM   #4
slufoot80
Member
 
Registered: Nov 2011
Posts: 61

Original Poster
Rep: Reputation: Disabled
Smile 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.
 
Old 10-31-2012, 09:48 AM   #5
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 5,954
Blog Entries: 5

Rep: Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755
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
 
Old 11-02-2012, 11:24 AM   #6
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 753
Blog Entries: 2

Rep: Reputation: 194Reputation: 194
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.
 
Old 11-05-2012, 09:58 AM   #7
slufoot80
Member
 
Registered: Nov 2011
Posts: 61

Original Poster
Rep: Reputation: Disabled
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.
 
  


Reply

Tags
password


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to catch function return value in solaris nagendrar Solaris / OpenSolaris 3 05-03-2010 01:51 AM
dpkg return error :post installation script return an error code (1) grimfold Debian 2 09-10-2009 01:55 PM
Request : set passwords for many users [user accounts exist] using a shell script bv_uma Linux - Software 3 08-19-2006 09:01 AM
Need shell script to set passwords for already created users naren_0101bits Programming 2 08-28-2005 02:02 PM
Moving Solaris Users and Passwords to Linux chicofidel Linux - Newbie 6 08-19-2005 06:55 AM


All times are GMT -5. The time now is 04:25 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration