Share your knowledge at the LQ Wiki.
Go Back > Forums > Other *NIX Forums > Other *NIX
User Name
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.


  Search this Thread
Old 04-21-2010, 11:26 PM   #1
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 217

Rep: Reputation: 30
Question 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:

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.
Old 04-22-2010, 04:20 PM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,075
Blog Entries: 14

Rep: Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251Reputation: 1251
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:
Old 04-23-2010, 05:10 AM   #3
Senior Member
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,300

Rep: Reputation: 102Reputation: 102

Expect is your friend. You can use this code.

# 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

Last edited by vikas027; 04-23-2010 at 06:47 AM. Reason: typo error
1 members found this post helpful.
Old 04-24-2010, 09:17 AM   #4
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 217

Original Poster
Rep: Reputation: 30
I see; I will research more into 'expect'. This command/phrase is totally new to me.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
stdin redirect billysdomain Linux - Newbie 5 12-17-2009 03:03 PM
bash stdin redirect Yustu Programming 3 03-13-2009 08:01 PM
How to redirect the stdin and stdout of child process which exec interactive prog? john.daker Programming 1 11-04-2008 09:27 AM
redirect stdin/stdout of running process xtravar Linux - Software 3 03-06-2004 08:54 PM > Forums > Other *NIX Forums > Other *NIX

All times are GMT -5. The time now is 10:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration