1*96c8483aSYuri Pankov#
2*96c8483aSYuri Pankov# CDDL HEADER START
3*96c8483aSYuri Pankov#
4*96c8483aSYuri Pankov# The contents of this file are subject to the terms of the
5*96c8483aSYuri Pankov# Common Development and Distribution License (the "License").
6*96c8483aSYuri Pankov# You may not use this file except in compliance with the License.
7*96c8483aSYuri Pankov#
8*96c8483aSYuri Pankov# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*96c8483aSYuri Pankov# or http://www.opensolaris.org/os/licensing.
10*96c8483aSYuri Pankov# See the License for the specific language governing permissions
11*96c8483aSYuri Pankov# and limitations under the License.
12*96c8483aSYuri Pankov#
13*96c8483aSYuri Pankov# When distributing Covered Code, include this CDDL HEADER in each
14*96c8483aSYuri Pankov# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*96c8483aSYuri Pankov# If applicable, add the following below this CDDL HEADER, with the
16*96c8483aSYuri Pankov# fields enclosed by brackets "[]" replaced with your own identifying
17*96c8483aSYuri Pankov# information: Portions Copyright [yyyy] [name of copyright owner]
18*96c8483aSYuri Pankov#
19*96c8483aSYuri Pankov# CDDL HEADER END
20*96c8483aSYuri Pankov#
21*96c8483aSYuri Pankov
22*96c8483aSYuri Pankov#
23*96c8483aSYuri Pankov# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*96c8483aSYuri Pankov#
25*96c8483aSYuri Pankov
26*96c8483aSYuri Pankov#
27*96c8483aSYuri Pankov# NAME
28*96c8483aSYuri Pankov#       passwd.exp
29*96c8483aSYuri Pankov#
30*96c8483aSYuri Pankov# DESCRIPTION
31*96c8483aSYuri Pankov#       The Expect script will change the passwd of a user
32*96c8483aSYuri Pankov#
33*96c8483aSYuri Pankov
34*96c8483aSYuri Pankov
35*96c8483aSYuri Pankovset timeout 5
36*96c8483aSYuri Pankovset name [lindex $argv 0]
37*96c8483aSYuri Pankovset passwd [lindex $argv 1]
38*96c8483aSYuri Pankov
39*96c8483aSYuri Pankovspawn passwd  $name
40*96c8483aSYuri Pankovexpect {
41*96c8483aSYuri Pankov	timeout {
42*96c8483aSYuri Pankov		send "\r"
43*96c8483aSYuri Pankov		send_error "\n passwd is time out\n"
44*96c8483aSYuri Pankov		exit 1
45*96c8483aSYuri Pankov	}
46*96c8483aSYuri Pankov
47*96c8483aSYuri Pankov	"User unknown:" {
48*96c8483aSYuri Pankov		send_error "\n User $name doesn't exist\n"
49*96c8483aSYuri Pankov		exit 1
50*96c8483aSYuri Pankov	}
51*96c8483aSYuri Pankov
52*96c8483aSYuri Pankov	"New Password" {
53*96c8483aSYuri Pankov		send "$passwd\r"
54*96c8483aSYuri Pankov		sleep 2
55*96c8483aSYuri Pankov		expect {
56*96c8483aSYuri Pankov			timeout {
57*96c8483aSYuri Pankov				send "\r"
58*96c8483aSYuri Pankov				send_error "\n passwd is time out\n"
59*96c8483aSYuri Pankov				exit 1
60*96c8483aSYuri Pankov			}
61*96c8483aSYuri Pankov			"Re-enter new Password:" {
62*96c8483aSYuri Pankov				send "$passwd\r"
63*96c8483aSYuri Pankov				sleep 2
64*96c8483aSYuri Pankov			}
65*96c8483aSYuri Pankov		}
66*96c8483aSYuri Pankov	}
67*96c8483aSYuri Pankov}
68*96c8483aSYuri Pankov
69*96c8483aSYuri Pankovsend_user "\n"
70*96c8483aSYuri Pankovexit 0
71