Skip to main content
Explanation was wrong; cat is connected to outer stdin, not stdout of `echo`
Source Link

I found this clever solution: (echo -e "cmd 1\ncmd 2" && cat) | ./shell_executable

This does the trick. cat will pump inread additional input (until EOF) and pass that to the output ofpipe after the echo has put its arguments into the input stream of shell_executable & wait for more inputs until EOFshell_executable.

I found this clever solution: (echo -e "cmd 1\ncmd 2" && cat) | ./shell_executable

This does the trick. cat will pump in the output of echo into input stream of shell_executable & wait for more inputs until EOF.

I found this clever solution: (echo -e "cmd 1\ncmd 2" && cat) | ./shell_executable

This does the trick. cat will read additional input (until EOF) and pass that to the pipe after the echo has put its arguments into the input stream of shell_executable.

Source Link

I found this clever solution: (echo -e "cmd 1\ncmd 2" && cat) | ./shell_executable

This does the trick. cat will pump in the output of echo into input stream of shell_executable & wait for more inputs until EOF.