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 pretty fast.
Looking forward to your participation in the forums. Have fun with Linux.
Kind regards,
Eric