How to send part of the data through the pipe/file and later interactively

expectpipestdin

I have a command I want to run, let's call it program. It is an interactive program similar to bash or python REPL.

I want to start this program with some predefined input. I tried program << "some_commands". But after executing some_commands it finishes and I cannot continue interacting manually.

If this program was bash I would use .bashrc for this purpose.

What is the correct way to use such a program with the predefined starting input?

Best Answer

You can also do this without using expect:

{ echo foo ; cat ; } | command
Related Question