Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-13-2009, 04:57 AM   #1
LQ Newbie
Registered: Nov 2007
Posts: 27

Rep: Reputation: 15
expect script to change user password


i have written a small expect script to change the user passwod.


spawn passwd [lindex $argv 0]
set password [lindex $argv 0]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof

when i execute the above script has

./ testuser Welcom@123

it is giving the below error and password is not getting changed

./ testuser Welcome@123
spawn passwd testuser
Changing password for user testuser.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Could you please correct the issue, where i am wrong

thanks in advacne

Old 03-13-2009, 05:36 AM   #2
Registered: Mar 2009
Distribution: Debian,Centos
Posts: 30

Rep: Reputation: 16
Originally Posted by sherimm View Post
spawn passwd [lindex $argv 0]
set password [lindex $argv 0]
The arguments don't look right. Seems like you are using the username as a password value. Try the following:

set password [lindex $argv 1]


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
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 09:06 PM
Locking out a user when password expires, but allowing them to change their password kaplan71 Linux - Security 5 06-27-2008 07:12 PM
LXer: How to change Linux /UNIX system password-using a web based PHP script user interface LXer Syndicated Linux News 0 08-05-2006 08:33 PM
Can my shell script change the password of user ? prabhatsoni Linux - Software 1 05-27-2006 02:06 AM
Need help creating/using a password dialog box for an Expect script crazygyhrous Linux - General 1 12-13-2005 11:48 AM > Forums > Linux Forums > Linux - Software

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

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