Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

script question

Posted on 2002-06-30
10
Medium Priority
?
331 Views
Last Modified: 2010-04-21
how can I write a command line answer in a script , for example  if I want to make a script to input a password for a user,
just like this "passwd pgsql" , but I want to write the password in the script .
0
Comment
Question by:csdnchen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7121235
for common purpose you simply can use a file to read the answers from, like:
  your-script < file-containing-answers
or:
  echo answer | your-script

If it is for programs requesting paswords (like telnet), you need a special script language like expect to do it.
0
 
LVL 6

Expert Comment

by:bira
ID: 7122136
echo "Enter the password"
stty -echo
read password
stty sane
echo "The Password is : $password"
0
 

Author Comment

by:csdnchen
ID: 7125809
I want to auto input the password by script , I means to write a script to make a user password , the password is written in the script , not input at runtime, it seems not run:
 
echo "password" |echo "password"|passwd username
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:NTIVER
ID: 7126507
listening...
0
 
LVL 9

Expert Comment

by:PeterMac
ID: 7126924
ahoffman is right, most programs requesting passwords will go direct to current tty device, not use stdin for password entry, you need something to emulate keyboard entry of password, ie put password directly into keyboard buffer. Even this will not work with all of them, I have known programs deliberately flush keyboard buffer between requesting "username", and "password", to ensure password is manually entered.
0
 
LVL 1

Expert Comment

by:dkloes
ID: 7133706
Not sure what version of Unix you are running.  In Red Hat Linux, the following passwd command works:

echo "password"|passwd root --stdin
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7133798
which passwd will do that, /usr/bin/passwd?
0
 
LVL 1

Expert Comment

by:dkloes
ID: 7146629
Yes.  RH Linux 7.1.

Sorry it took so long to get back.  Did not realize that it had been awhile since I posted and my old e-mail address was being used so did not receive notification.
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7921503
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- PAQ, no points refunded

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7967170
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question