You can use GNU screen’s copy and paste commands.
Quick tutorial:
- Open screen:
screen
(orscreen myprog my args here
) - Run your program, producing output you want copied
- Enter copy mode: Control+a+[
- Move your cursor to the start point
- Hit Enter
- Move your cursor to the end point
- Hit Enter
- Paste: Control+a+]
Screen is much more powerful than that (I use it to tab several virtual terminals without the need for a special terminal emulator, and also so that I don’t loose my sessions when X crashes or something). To get out of screen, simply end your shell session, or type Ctrl+a, Ctrl+\.