in reply to open with a command

Well you could mess around with the techniques in perlipc, but it seems like Expect might be a good fit for what you're trying to do.