Solved

script question

Posted on 2002-06-30
10
291 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 20

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
non-interactive authentication of sftp command in AIX 5.3 15 184
CPU monthly average? 12 104
Linux :how to provide sudo access to the user 13 88
dot directory in FreeBSD??? 4 72
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…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now