Solved

automatizing password generation with expect

Posted on 1998-09-28
2
350 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
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 …
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
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…

707 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

19 Experts available now in Live!

Get 1:1 Help Now