?
Solved

automatizing password generation with expect

Posted on 1998-09-28
2
Medium Priority
?
371 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 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

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