in reply to 2 way pipe?

Depending on what command you're trying to run Expect may also be of interest.