LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Other *NIX (https://www.linuxquestions.org/questions/other-%2Anix-55/)
-   -   how to redirect STDIN to hp-ux's passwd (https://www.linuxquestions.org/questions/other-%2Anix-55/how-to-redirect-stdin-to-hp-uxs-passwd-803427/)

chickenjoy 04-21-2010 10:26 PM

how to redirect STDIN to hp-ux's passwd
 
I have this script that will auto fill in the password for a new account created in the system:

Code:

echo $PASW1 | passwd --stdin userid
This works in linux, but in hp-ux 11x it wont work. I've already checked the man pages and there is no entry or option on how to replicate the same for the

is it -n? didn't work.

MensaWater 04-22-2010 03:20 PM

HP-UX passwd command does not allow for stdin because it is an interactive command.

There are some ways to automate this - there is a good discussion here:
http://forums13.itrc.hp.com/service/...hreadId=899229

vikas027 04-23-2010 04:10 AM

Expect is your friend. You can use this code.

Code:

#!/usr/bin/expect
# USAGE : ./script username new_password

spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof


chickenjoy 04-24-2010 08:17 AM

I see; I will research more into 'expect'. This command/phrase is totally new to me.

thanks!


All times are GMT -5. The time now is 05:00 AM.