2
votes

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?

2

2 Answers

5
votes

You can run the program with input redirected:

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

You can do using --args option giving program executable followed by arguments as below,

 % gdb --args ./program arg1 arg2