Link to home
Start Free TrialLog in
Avatar of ritru
ritru

asked on

Script writing for a password prompt

I writing a shell script to import a password on a password prompt.. How can I enter a password on a password prompt without typing the words in...For example if I do su -help the password prompt shows up. How can I import the password automatically into the script which then writes in when the password prompt shows up...Here's a example of my script or would I need to write this C


start="su -help"
export start

           echo "Starting the user help"
           $start echo
           ????????????(password prompt)
Avatar of chris_calabrese
chris_calabrese

stty -echo
read passwd?"passwd: "
echo
stty echo


But be careful. If you pass $passwd to on the command line then it will be viewable with the ps command. You need to pass it on stdin or in a file. There is also a whole other can of worms related to what you're using to check that the password is correct, how the password database is stored, how to force using good passwords, etc., etc.
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial