Solved

script question

Posted on 2002-06-30
10
316 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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

679 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