Solved

automatizing password generation with expect

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Node.js 11 80
site - site VPN 3 79
how to specify windows account to use for connection manager in SSIS package 25 76
Firewall support--by the month? 10 61
Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
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.
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

732 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