The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
why the below script is not working ., konankir Shell Programming and Scripting 14 03-27-2008 04:32 PM
bdf script not working !! kpatel786 Shell Programming and Scripting 3 11-16-2007 11:10 AM
Pls. Help my script not working as it should cocoabeauty1 Shell Programming and Scripting 1 07-28-2007 06:11 PM
FTP script not working rookie250 Shell Programming and Scripting 2 12-19-2006 02:49 AM
emailed reset password is not working zyx Forum Support Area for Unregistered Users & Account Problems 1 10-20-2005 01:08 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 3.00 average. Display Modes
  #1 (permalink)  
Old 06-04-2008
upengan78 upengan78 is offline
Registered User
  
 

Join Date: Jun 2008
Location: Texas
Posts: 142
Exclamation script not working as intended for password[SOLVED]

Hi

I have a script which uses expect and I run it on solaris 10 to set a common password for all users. I run it as `./script password` but when I tried to log into the system then I do not really have to type password, pressing ENTER on keyboard logs the user into system. (ssh)

This below is script and I feed it with a file with user names.


Quote:
#!/bin/ksh

ChangePasswd()
{
/usr/local/bin/expect <<EOF
set newpassword [lindex $argv 0]
spawn passwd $user
expect "New Password: " ## not expect "password:"
send "$newpassword\r"
expect "Re-enter new Password: " ## not expect "Re-enter"
send "$newpassword\r"
expect eof
EOF
}
#while read -p "Enter Userid:" user
while read user
do
if [[ $user != '' ]];
then
ChangePasswd $user
fi
done <ab
################### ab is file with user names

Last edited by upengan78; 06-05-2008 at 03:53 PM.. Reason: SOLVED
  #2 (permalink)  
Old 06-05-2008
upengan78 upengan78 is offline
Registered User
  
 

Join Date: Jun 2008
Location: Texas
Posts: 142
any one ?well atleast give me a ready solution on setting passwords for large users either password = userid or password = common for everyone

I would make the users change passwords at first login later, which need not be part of script.just need to set password easily.


Also if please remember the script will be run on solaris 9 or 10 OS and not on Linux

Thanks
  #3 (permalink)  
Old 06-05-2008
upengan78 upengan78 is offline
Registered User
  
 

Join Date: Jun 2008
Location: Texas
Posts: 142
I found it myself

Quote:
#!/bin/ksh

ChangePasswd()
{
/usr/local/bin/expect <<EOF
spawn passwd $user
expect "New Password: "
send -- "$2\r"
expect "Re-enter new Password: "
send -- "$2\r"
expect eof
EOF
}
#while read -p "Enter Userid:" user
while read user
do
if [[ $user != '' ]];
then
ChangePasswd $user $1
fi
done <ab
## ab file has the list of users whose password I am changing

I run the above script as ./script <password I want>

that sets the password for all users to what I want !
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate 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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0