I'm guessing this will work, but it's only a guess since we don't know how your program is reading the responses: use a here-doc, and put the input for command B after invoking command B
example_program <<'END'command_Acommand Binput_herecommand CEND