you don´t need script. If you are connected to console and want to reboot switch then type command reload and confirm with enter.
Switch should boot automatically if you didn´t configure manual boot.
However cisco switches should work fine without reset for many months. So I don´t see purpose of this.