This makes me wonder... Maybe some strange versions of echo expect that the hex string collapses the zeroes, "\x1" instead of "\x01"? Crazy, but maybe explains the failures you were seeing.

You could replace the `Rex::Text.to_hex(...)` call with `@exe.bytes.map { |b| sprintf("\\\\x%x", b) }.join` to test