Shell script to capture keyboard actions

How to capture all keystrokes using shell script. Is there any command related to keyboard actions.

+5
source share
2 answers

Check it out trap.

For example, type in the console:

trap "echo \"Arrrrggghhhh\"" INT

Now click Ctrl+ C- fun fun :)

+1
source

If you want to register all input and output data, you can use the command script.

$ 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
0
source

All Articles