I have a program that reads in input from the user and then prints out the memory location of where the input is stored in memory. It then asks if the users wishes to continue. When "Y" is entered, the program waits again for user input. If "N" is entered, the program exits. Here is a sample of how the program works.
Give me data to dump: ABCD 0xbeb9eaf8: 41 42 43 44 Dump again (y/n): y Give me data to dump: ADDD 0xbeb9eaf8: 41 44 44 44 Dump again (y/n): n
When I try to feed python output into the program instead using the command
echo `python -c 'print "A"'` | ./program
It results in an infinite loop like this:
Give me data to dump: 0xbeb31af8: 41 Dump again (y/n): Give me data to dump: 0xbeb31af8: 41 Dump again (y/n): Give me data to dump: 0xbeb31af8: 41 Dump again (y/n): Give me data to dump: 0xbeb31af8: 41 Dump again (y/n): Give me data to dump: 0xbeb31af8: 41 Dump again (y/n): Give me data to dump: 0xbeb31af8: 41 Dump again (y/n): Give me data to dump: 0xbeb31af8: 41
How do I pipe the python output to the program so that this infinite loop does not occur? The architecture is arm.
./program
's reading logic is broken. Does it work if you provide then
as well?python -c 'print "A"'
is perfectly capable of writing tostdout
, you don't need to wrap it inecho `...`
.A
followed by a newline followed by an infinite number of Control-D characters. Can you verify that your program does the same thing when you do that?