Bash answer prompt

I am working with a script to simplyfy some operations where I work, but one of the programs needs me to enter a password.
It will as me "Please enter the administrator password:"
Is there a way to make a bash script to automatically answer the question with the needed password?

I am looking at either have the password in clear text directly in the script, or read the script from a file only readable by a certain user.

I know, none of them are "secure" as the password prompt is there to create security, but the security is not really needed for us, right now it's more a bother to us.

I have been trying with things such as:
# program remove -Uadmin < /home/user/passwd_file
or as another suggestion was:
# yes password | program remove -Uadmin

Which application is asking for the password? Have you considered using expect?

I'm guessing the application reads from TTY since redirecting from STDIN didn't work. As "ilikecows" said, check with "expect". If "program" is actually "sudo", then I can help you with that ... there's a NOPASSWD option you can add to certain user-command pairs so this doesnt happen. If it's ssh, you should use a public/private keypair for that user.

Thank you ilikecows, expect did the job :slight_smile:
I didn't know about it until now :slight_smile:

The program asking for the password is a program made specifically for our organization, so even if I told you the name, I am quite sure you wouldn't know what it's all about. :slight_smile: