Solved

automatizing password generation with expect

Posted on 1998-09-28
2
364 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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