The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Changing cursor position using shell script balamv Shell Programming and Scripting 2 06-02-2008 01:10 PM
Need help with Expect and Shell script tonan Shell Programming and Scripting 1 04-10-2008 10:45 PM
changing unix user password using script mani_um AIX 5 09-04-2007 11:33 PM
Expect Script....encrypt password and use cubs0729 Shell Programming and Scripting 2 12-01-2006 05:07 AM
Using expect script in a shell script Naresh Kumar Shell Programming and Scripting 3 06-10-2006 08:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-14-2006
chellam chellam is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 1
Password changing in a Script (shell and expect)

Hi,

Does anybody know how to change the password on multiple servers with a script. I have 300 Sun boxes and the password expiry is set to 30 days. Im in a process to build a script using expect. Need a help from an expert who has already done it.

Regards,
Vinod
  #2 (permalink)  
Old 08-14-2006
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
  
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 521
For yourself?
Get a list of all the boxes in a file, either IPs or hostnames.
The expect script would look something like:
Code:
#!/usr/local/bin/expect --  
spawn telnet [lindex $argv 0]
expect  ogin:
send loginName\r
expect ssword:
send yourPasswd\r
expect yourprompt
send "passwd  loginName\r"
expect  ssword:
send yourPasswd\r
expect ssword:
send newPasswd\r
expect ssword:
send newPasswd\r
expect yourPrompt
send exit\r 
expect  close
exit 0
The above example assumes that the passwd command is going to first ask you for your passwd, then you'll have to enter the new passwd twice.
Before you run it against all boxes, test it with one box. Make sure you log into the box first on another terminal, just in case.
Code:
myscript.exp  hostname
If no issues, remove the hostname from your sever list, then do
Code:
for x in $(cat boxList.txt); do
myscript.exp  $x
done
Quick note, if your prompt is $ or ends in $, you need to comment it out in the expect script., so expect sees it as a regular character. Otherwise it'll go very slow.
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 08:33 PM.


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