I was working on some code for our server hosting system last night and I needed a way to execute commands on a remote system's console. My actual use case is a bit more complicated since I'm sending commands to a Xen Virtual Server console where SSH may not be enabled (ssh-ing into the host) but I thought this would be a good start.
You can send commands to a remote host using SSH alone as shown here, but since this is an interactive console session I used ruby to listen for the console prompts and enter the correct response. See below: