0

So typically when you redirect input with a command like find . | grep -i pineapple it just evaluates find ., and that comprises all of the input for grep -i pineapple.

However, I need to write a script that runs a program, gives it some input, reads some of the output, keeps the program running, and then sends some more input, based on the output earlier. For instance consider a C program that uses scanf twice, if I redirect normally I have to specify the input for both calls to scanf before running the program, however what I want to give to the second call to scanf depends on what the program outputs between the two calls.

I've tried doing it with ./pineapple >&0 <&1 & so I can just access the programs input and output as stdout and stdin, but that didn't work, not sure what I was expecting. The input is in binary format, and what the program outputs will not always be the same for the same input, if that's relevant. Is there any easy way I can do what I described?

ilkkachu
  • 138,973

0 Answers0