Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to record my own keystroke data for some academic research. I wrote a regular keylogger for Windows, but now I need to write one for a Unix environment, with the constraint that I have only user-level access. Furthermore, I'm only in the terminal, so this problem is more narrow in one sense.

What would be the best way to do this? Is there some easy way to sort of fork my input so that it goes to a special program as well as to Bash?

I'm using Python or Ruby if there's a lot of code involved, or Bash would work.

The system is Red Hat Enterprise Linux 6.3 if it matters.

Update: I should have listed out more detailed requirements:

  • Need to record timing somehow (script -t seems to be fine)
  • Need to handle special keystrokes (it matters if a Ctrl or a shift was hit in-between keystrokes); so far as possible, every key event should be handled
  • Optional: Might also be good to differentiate key down and key up events for more fine-grained data.
share|improve this question
add comment

1 Answer 1

If you're only using the terminal, there's an easy solution: script does what you want and more: it logs both input and output.

share|improve this answer
    
This looks very handy, especially with the -t option. Is there any way to handle all the special keystrokes as well, such as shift and ctrl? I will update the question. –  dafrazzman Dec 6 '12 at 16:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.