0

I have my own command line program which I am running on the terminal. How might I redirect the output from this program to file so that I can see a hex representation of it? I also wish the control characters outputted from the program to be saved to hex.

UPDATE

My program also receives commands on the terminal via std input. It seems doing:

myprogram 9889 > output.txt

or even

myprogram 9889 | xxd

disrupts the program in some manner such that I cant seem to get the program to respond to inputted commands.

Baz
  • 12,713
  • 38
  • 145
  • 268

3 Answers3

2

you did not mention the operating system you are using. in Linux you can use hexdump

your_console_app | hexdump -C
Alex P.
  • 30,437
  • 17
  • 118
  • 169
1
program > file.txt

This will redirect all STDOUT of program to file.txt

If you want to read more about redirection, read me

Suku
  • 3,820
  • 1
  • 21
  • 23
0

Don't do this.

It's better to save the file as is, i.e. save the exact bytes output by your program.

Then, when you want to display the data, view it as hexadecimal data.

$ program >output.txt
$ hexdump -C output.txt

This uses the hexdump program which is common in Linux. You should have it.

Cyclonecode
  • 29,115
  • 11
  • 72
  • 93
unwind
  • 391,730
  • 64
  • 469
  • 606
  • When I try this, only the startup banner from my program is stored to the file. When I start entering data on the stdin (after startup), the responses are missing from the hex log. – Baz Jan 18 '13 at 16:36