UNIX or Linux script to automate sending commands via telnet

An example of a shell script to automate the sending of commands via telnet. Perhaps not the most elegant way to send commands, but it can be quickly set up. In this case we are rebooting a Proxim point to multipoint wireless base station.

WARNING! This script is currently used on a segregated network and the server used to launch the script is accessed via SSH. Never use telnet over unprotected or unencrypted networks.

(echo "password"; sleep 2; echo -e "reboot 0\r"; sleep 2;) | telnet device_ip_address > result.out