Login via script

Hi, i have a little question:

How to login to routeros via script?
For example, I am doing sth:

#script:
tool mac-telnet
beep
quit
#end

The problem is that MT wants from me login and pass after first command. How to tel my script login and password to device?