views:

41

answers:

2

How to capture all keyboard strokes using shell script .Is there any command that is related to keyboard activities.

A: 

Check out the trap command.

For example, type in your console :

trap "echo \"Arrrrggghhhh\"" INT

Now press Ctrl + C - fun fun :)

lucas1000001
A: 

If you would like to log all input and output, you can use the script command.

$ script transcript.txt
Script started, file is transcript.txt
$ echo 'Hello, world!'
Hello, world!
$ exit
Script done, file is transcript.txt
$ cat transcript.txt 
Script started on Thu 09 Sep 2010 03:06:56 PM EDT
$ echo 'Hello, world!'
Hello, world!
$ exit

Script done on Thu 09 Sep 2010 03:07:06 PM EDT
Brian Campbell
@Brian:It just captures the shell commands and not the strokes that are made on browser or editors rit?
Rajeev
@Rajeev `script` captures all input and output to the terminal, including keystrokes that are made in editors or other programs. It only captures input and output which go through the terminal; if a program opens a new window, or otherwise gets keyboard input from some other source than the terminal, `script` will not catch it. If you want something more than that, please edit your question to clarify what you're looking for.
Brian Campbell
@Brian:As u know the requirements,i want to capture all key strokes.Let me know if i have to edit the question and do let me know of the solution
Rajeev
@Rajeev You are still being unclear; I do not know "know the requirements." Do you want to capture all keystrokes coming into the computer at all, whether or not they go through the terminal? If so, you're probably looking for a keylogger. You can find those by Googling for them.
Brian Campbell