Mt Xia: Technical Consulting Group

Business Continuity / Disaster Recovery / High Availability
Data Center Automation / Audit Response / Audit Compliance

-
Current Location
-

css
  Downloads
    Scripts
      Expect

-

digg Digg this page
del.icio.us Post to del.icio.us
Slashdot Slashdot it!


Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com

FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Script: change_passwd.exp

#!/usr/bin/expect -f
#
# Author: Chris Narcouzi  cnarcouz [ at ] cswg [ dot ] com
# 
# This script changes the password of a user without being prompted for
# the passord itself. It is used in conjuction with another ksh script
# called change_passwd.sh that provides the UNIX box name, the userid, and
# the root password. This script sets the user's password to "1234" but
# you can change it to anything you like.
# 

proc usage {} {
    send_error "usage: change_passwd  \n"
    exit 1
}

if {[llength $argv] < 2} usage

set hostname [lindex $argv 0]
set userid [lindex $argv 1]
set rootpasswd [lindex $argv 2]
set timeout -1
spawn telnet $hostname
match_max 100000
expect -exact "login: "
send -- "root\r"
expect -exact "root's Password: "
send -- "$rootpasswd\r"
expect -exact "root@$hostname>"
send -- "passwd $userid\r"
expect -exact "New password: "
send -- "1234\r"
expect -exact "new password again:"
send -- "1234\r"
expect -exact "root@$hostname>"
send -- "exit\r"
expect eof


Script: change_passwd.sh

#!/bin/ksh
#
# Author: Chris Narcouzi  cnarcouz [ at ] cswg [ dot ] com
# 
# This script provides input to Expect script called change_passwd.exp.
# The change_passwd.exp script actually telnet to the UNIX box provided
# with the root password provided and change the userid provided password.
# The password for the user is set in change_passwd.exp script.  You can
# modify it in that script. You can tailor this script and use a for loop
# to perform mass password changes.

root_passwd="password"
UNIX="unix-box-name"
userid="userid"

expect -f /your/directory/change_passwd.exp $UNIX $userid $root_passwd

-
Change Password
-
 


FREE Domain Registration
included with Web Site Hosting
Tools, Social Networking, Blog

www.siteox.com

Business Web Site Hosting
$3.99 / month includes Tools,
Shopping Cart, Site Builder

www.siteox.com