Sorry Admins, I should have posted this in OpenBSD General or Programming.

I'm using OpenBSD 4.4. I have a power strip that can be controlled through a RS-232 serial console. It works great from cu and minicom but it doesn't support any way of controlling it from programs, just a console designed for humans. I want to be able to send commands and read the output of the commands through a shell script or some other program that can be called from a shell script. I'm not necessarily looking for solutions to the following problems I'm just looking for any way to make this work.

I looked into using a C program that interacts with the serial ports using termios.h, unistd.h and fnctl.h but it looks like I would be reinventing the wheel and doing tons more work than I need to.

I also tried using expect to control cu. This seems like the best way of doing it since expect is designed to interact with CLI's that were designed for humans. It works fine and turns things on and off until expect reaches a read statement following an expect statment. See the bottom code window.