It looks like expect should handle it properly, but it wasn't working for me. Still sorting that out.