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)
start="su -help"
export start
echo "Starting the user help"
$start echo
????????????(password prompt)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.