rebooting by telnet on script

Hello there.
I wonder if there is a way to develope a script which be able to reboot an external device such a motorola PTP600.
Here are the 3 comands i need to perform, I could not do it by scripting, I have heard I need some more tools to do it

telnet 10.12.1.5
passwd
reboot
yes

the first line carries out telnet connection, the second one is the password that device asks for, the third one is the reboot command for the device, fourth line confirm the action for rebooting. After each command I need to put an ENTER.

How can I perform this task by using RB1000? if any body can help me, THANK YOU A LOT
Ivan PErino

RouterOS script is not capable doing this.

you cannot do this on routeros, but you can do this on linux box using expect scripts.