streamterminalgdbstdin

Simulating echo input with GDB


So I am trying to debug a program which requires the user to input some text through the terminal:

$ echo 'here is the text' | ./program

How do I simulate that input in GDB?


Solution

  • You can run the program with input redirected:

    echo 'here is the text' > intput.txt
    gdb ./program
    (gdb) run < intput.txt