read terminal command

hi
how to read terminal command,
just i want to read all command which write on terminal
so please tell me any system call, api avilable in c for above purpose

do you wanna of previous commands

which you run in terminal

for this type

history

i dont understand wether your problem about this or not

ignore if not

my problem is i want to create one file which store all command or which write on terminals (bad command) in day, for that i read console terminal

now clear problem ............?

hi u can write a deamon proc in C to read all the command in the terminal.

use the "system" system call in the c program and redirect all the commands in the history to a file to analyse.writing a deamon allows u to do this in background.

system("history>test.$$);

include this in the code.

mail me if u have any concerns

system ("history >/root/txtx.txt");
not working,it run properly(create file txtx.txt ) but file doent contain any thing

My strange idea:
You can remove ~/.bash_history
and then place FIFO of that name:
mkfifo ~/.bash_history
and then run some program for reading and saving
all commands.

Or maybe you would like to use "script" command.

If you need a keylooger - the kind of program you're describing - odys mentioned the script utility.

IF this is a real security problem, put something like this in /etc/profile

if [[ $USER = " badguy" ]]; then
  script <somedirectory the user can write to>/filename
fi

This way the user cannot circumvent logging by editing the .profile or .bashrc file.