Serial from ruby, sometimes yes sometimes no

Hi. I'm in the middle of something pretty weird. I've got an Arduino that turns some lights on when it reads a 7 from its serial connection. In the Arduino serial monitor, this always works beautifully.

What I'm trying to do is have that 7 be sent by a ruby script:

The ruby script works, but only when the Arduino serial monitor is running. Weird!

Here are some things I've tried:

Running "echo 7 > /dev/tty.usbserial-A9003Wpf" from the command line. Only works when the Arduino serial monitor is open. (Which is to be expected, because the command isn't actually setting up a serial connection with a proper baud rate, etc.?)

Changing the baud rate on the ruby script, just to make sure the script isn't somehow hijacking the Arduino serial monitor's connection. It isn't: with the wrong baud rate the ruby script will never work.

I'm stumped. Ideas?

I tried a quick Processing sketch, serial seems to work just fine. Hmm.