LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 11:26 PM   #1
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 200

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, 04:20 PM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
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, 05:10 AM   #3
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Debian, OS X
Posts: 1,270

Rep: Reputation: 99
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 06:47 AM. Reason: typo error
 
1 members found this post helpful.
Old 04-24-2010, 09:17 AM   #4
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 200

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

thanks!
 
  


Reply


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


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

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration