Automating Interactive password change


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Automating Interactive password change
# 1  
Old 11-11-2011
Automating Interactive password change

I have written the below scripts .

Code:
ldap_pwd_prompt.ksh
#!/usr/bin/ksh
passwd -r ldap

interactive_pwd_change.exp
#!/usr/local/bin/expect
set timeout 10
set curpass [lindex $argv 0]
set newpass [lindex $argv 1]
spawn ./ldap_pwd_prompt.ksh
expect "Enter existing login password:"
send "$curpass\r"
expect "New Password:"
send "$newpass\r"
expect "Re-enter new Password:"
send "$newpass\r"
interact

the error it throws is below and hangs after that.Please let me know how this can work.

Code:
./interactive_pwd_change.exp myoldpwd mynewpwd
[2]     10452
sdsas01:/home/dr46014> spawn passwd -r ldap
sh: /usr/local/bin/stty: not found
Enter existing login password:
New Password:
Re-enter new Password:


Last edited by vbe; 11-11-2011 at 11:45 AM.. Reason: codetags next time for your code and data!
# 2  
Old 11-11-2011
Isn't interact to let the user interact with the session you opened?
If so where is the exit?
# 3  
Old 11-11-2011
i tried with exit but still its not working.

Below is the error :
Code:
$spawn ./ldap_pwd_prompt.ksh
sh: /usr/local/bin/stty: not found
Enter existing login password:
New Password:
Re-enter new Password:
Permission denied

and it does not go to the prompt again.
Code:
#!/usr/local/bin/expect
set timeout 10
set curpass [lindex $argv 0]
set newpass [lindex $argv 1]
spawn ./ldap_pwd_prompt.ksh
expect "Enter existing login password:"
send "$curpass\r"
expect "New Password:"
send "$newpass\r"
expect "Re-enter new Password:"
send "$newpass\r"
expect eof
exit;

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by vbe; 11-11-2011 at 01:51 PM.. Reason: typos
# 4  
Old 11-11-2011
Well two things (I don't get you...):
What are you trying to automate (for me this means no more intervention, so it is a batch...)?
If automating, what has interacting with the prompt to do?
# 5  
Old 11-11-2011
Quote:
Originally Posted by vbe
Well two things (I don't get you...):
What are you trying to automate (for me this means no more intervention, so it is a batch...)?
If automating, what has interacting with the prompt to do?
In our environment users dont have direct access to unix box.They will run a shell script using their old and new password and they will reset their password.So the paramters are old and new password while running the interactive_pwd_change.exp

I am not sure how to close it once the password change is done.So i was trying to run the shell script and test it so that it can be tested through the tool
# 6  
Old 11-11-2011
I am not user to have a good understanding...
If your users are to change their password by what I understand now "Not having an interactive shell", e.g . you are like a cron execution: there is no TTY... (and so explaining the stty message...). So I am wondering where can you pick that error from...
I, in order to execute scripts that may be called by batch sessions test the shell:
Code:
 if [[ $- = *i* ]]; then  #tty interactive test (VBE - 030306) 
#or
if tty -s  ;then #ksh...

# 7  
Old 11-11-2011
i am still not able to do.If you can let me know how to place the piece of code it will be great.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Password sent via reset password email is 'weak' and won't allow me to change my password

I was unable to login and so used the "Forgotten Password' process. I was sent a NEWLY-PROVIDED password and a link through which my password could be changed. The NEWLY-PROVIDED password allowed me to login. Following the provided link I attempted to update my password to one of my own... (1 Reply)
Discussion started by: Rich Marton
1 Replies

2. UNIX for Beginners Questions & Answers

Automating UNIX/Solaris password resets

Hi, we are running solaris 5.10 and looking for solutions to automate password resets? Plz assist. Thanks, Sridhar (6 Replies)
Discussion started by: chvgms
6 Replies

3. Shell Programming and Scripting

Automating an interactive process with EOF string

Hello, I'm running Stockfish chess engine ( Home - Stockfish - Open Source Chess Engine ) CLI on Linux in interactive mode which is working fine. root@ubuntu1950x:~# ./stockfish Stockfish 080218 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott setoption name Debug Log File... (2 Replies)
Discussion started by: prvnrk
2 Replies

4. Shell Programming and Scripting

automating username / password entry

I have a database that contains a list of server names, and the password for the root user on several servers (100+). I need to verify the passwords for each of the servers in an automated fashion because the database continues to grow. All of the users that I'm going to test are ROOT. I can't... (1 Reply)
Discussion started by: jbeck22
1 Replies

5. Shell Programming and Scripting

Automating Interactive script

I have a script that will install software on all remote host. At the end of the script it starts the install.sh part and goes into a interactive mode asking Yes or No questions and prompting to add a username and password. My question is how can I script this so that these questions are... (7 Replies)
Discussion started by: soupbone38
7 Replies

6. Shell Programming and Scripting

automating ssh session with password

Hi Can anyone help me in automate a ssh session with password using shell script (7 Replies)
Discussion started by: raghav288
7 Replies

7. Solaris

Non-interactive password change?

Does anyone know how I can do a non-interactive password change in Solaris 8 and 10? Using Sed to edit the passwd file, or Expect to automate the process has already been considered.... I'm looking for something more direct. Your guidance is appreciated. akbar (2 Replies)
Discussion started by: akbar
2 Replies

8. UNIX for Dummies Questions & Answers

Automating password change

Hi, I'm trying to create a shell to change some user password with random string. I've tried to use stdin redirection to supply the new password by a response file: passwd theuser < respfile but I continue to be prompted for supplying pwd via console keyboard. Can you help me to... (2 Replies)
Discussion started by: nisant
2 Replies

9. Shell Programming and Scripting

automating password ?

Hi all, I want to write a script which logs into a database (DB2). To do this i need to have a password. This will be done lots and lots of times, so i need to modify the script to automate the response to the password request. How do i this, because at present i do the following: db2 connect... (3 Replies)
Discussion started by: Liamo
3 Replies

10. Shell Programming and Scripting

Automating interactive scripts

Hi all, I am trying to write a program that will automate interactive scripts that use 'pkgadd'. Easily enough I can use 'pkgask' and a response file for most of what I want to do, but unfortunately there are parts of some pkg installations that are configured to only take input from /dev/tty!!... (2 Replies)
Discussion started by: bookoo
2 Replies
Login or Register to Ask a Question