Perhaps you aren't running in a terminal at all? I didn't actually read your message in detail, but try running with ssh -t. It will force allocation of a terminal.