Hello and Welcome to LinuxQuestions,
Have a look at expect. If you have it installed already you can start with the man pages:
If not, then have a look at Google, turns up tutorials like this one
Looking forward to your participation in the forums. Have fun with Linux.