Solved

automatizing password generation with expect

Posted on 1998-09-28
2
353 Views
Last Modified: 2013-12-23
Hello, I use Solaris 2.51.
I have got 7000 users, and I want to automatize the password generation with expect. But it doesn't work.

#!/usr/local/bin/expect
spawn passwd jgomez
set oldpass [lindex $argv 0]
set newpass [lindex $argv 1]
expect "Enter login password: "
send "$oldpass\r"
expect "New password:"
send "$newpass\r"
expect "Re-enter new password:"
send "$newpass\r"


When I run it, it delays little time. When I change a password with passwd it delays 4 seconds, because I have a lot of accounts. But if I use the except script it delays only one second. It is as if it doesn't proccess the passwd
command. I don't understand. Can you help me?

thanks very much.
0
Comment
Question by:jgomez
2 Comments
 
LVL 5

Accepted Solution

by:
n0thing earned 200 total points
ID: 1582390
This works for me. Try to run it as the user "jgomez" and make necessary changes as you need to go along.
#!/usr/local/bin/expect -f
# wrapper to make passwd(1) be non-interactive
# oldpasswd is passed as 1st arg, newpasswd as 2nd

set oldpassword [lindex $argv 0]
set newpassword [lindex $argv 1]
spawn passwd jgomez
expect "password:"
send "$oldpassword\r"
expect "password:"
send "$newpassword\r"
expect "Re-enter"
send "$newpassword\r"
expect eof

0
 

Author Comment

by:jgomez
ID: 1582391
Thanks very much. It works.
0

Featured Post

Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now