LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-21-2010, 10:26 PM   #1
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 239

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:

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

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

Rep: Reputation: 107Reputation: 107
Lightbulb

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

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

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

thanks!
 
  


Reply



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 02:03 PM
bash stdin redirect Yustu Programming 3 03-13-2009 07:01 PM
How to redirect the stdin and stdout of child process which exec interactive prog? john.daker Programming 1 11-04-2008 08:27 AM
redirect stdin/stdout of running process xtravar Linux - Software 3 03-06-2004 07:54 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX

All times are GMT -5. The time now is 09:00 PM.

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