keep track of the last 10 commands the user typed


 
Thread Tools Search this Thread
Top Forums Programming keep track of the last 10 commands the user typed
# 1  
Old 09-17-2006
keep track of the last 10 commands the user typed

Can I do it like this?

Code:
if (strcmp(argv[0], "history")==0)
                        {
                        argv[1] = "10";
                        execvp(argc[0],argv);
                        }

actually, it doesn't work,

How can I modify it?

Thanks
# 2  
Old 09-17-2006
What exactly are you trying to do? Are you supposed to take the action when the user gives in "history" as the command?

Another thing, what is argc[0]? Is argc also an array?
# 3  
Old 09-18-2006
I am implementing a UNIX shell program. It should be able to keep track of the last 10 commands the user typed. For instance, I input the command "history" at the prompt, the result will be displayed.

I try to use system call. However I don't know how to do it.
# 4  
Old 09-18-2006
Use "fc -l" to show a history of the last commands. Also "argv[0]" is the name of the program you are executing; "argv[1]" is the first parameter on the command line (argv[i] is the i-th parameter on the command line!)
ALTRUNVRSOFLN
# 5  
Old 09-18-2006
I mean the shell should provide a command "history" to display the last 10 commands a user typed.

So it needs to be programmed with c language.
How to do it?
# 6  
Old 09-18-2006
zhshqzyc

"fc" is the shell command to display - do "man fc"
ALTRUNVRSOFLN
# 7  
Old 09-18-2006
THANKS,
But You misunderstood my meaning.
Normally at unix prompt, you type "history" command, it will display all the commands you typed.
However I just want to display exactly 10 commands with exactly typed "history" command,
it means it must be programmed by system call.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to track what Commands run in a login session

Hi I need to track what commands run in login session in solaris whether it is root or any normal users in bash shell. My actual requirement is that when a user (nomal/root) login into the system, whatever commands he run, it should log into file on specified path . I don't require command... (4 Replies)
Discussion started by: hb00
4 Replies

2. UNIX for Advanced & Expert Users

Track activity of a user

Hi All We have a job which writes files to a server at a particular time. The files will be created by a particular user ID Today, during the execution of the job, it created a file to the server and the file sat on the server for sometime, but was deleted immediately at the end of the... (4 Replies)
Discussion started by: sparks
4 Replies

3. UNIX for Dummies Questions & Answers

How to track user activity?

Hi All Please can you help me with the following issue: A certain vendor installed an application in which for a user to log in; the user must use a user created/predefined by the application. And because this application has more than one user its difficult to track who did what and when,... (6 Replies)
Discussion started by: fretagi
6 Replies

4. AIX

track commands run as root after sudo

I'm looking for a way to track commands that are run as root after a user runs sudo su - root. I have a profile set up for root that will track the commands by userid but if we change the shell it only stores it in that shells history file. (2 Replies)
Discussion started by: toor13
2 Replies

5. AIX

"/" doesn't work on command prompt for searching commands last typed

When I use "/" to look for a particular command that I typed in the current session it says D02:-/home/user1/temp> /job ksh: /job: not found. D02:-/home/user1/temp> previously it used to fetch all the commands which had job in it.. for example subjob, endjob, joblist etc... may I... (7 Replies)
Discussion started by: meetzap
7 Replies

6. Homework & Coursework Questions

Track user log!

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The task is to measure the density of users that are logged on system. The program should check that every 30... (7 Replies)
Discussion started by: petel1
7 Replies

7. UNIX for Dummies Questions & Answers

Track user

Hi, i suddenly realized that a directory is deleted unfortunately there are many user have pervilages on this directory is there a way to track the user who delete this directory or atleast from now can i enable something so that i can track from now I think there is way from... (2 Replies)
Discussion started by: crackgeek
2 Replies

8. UNIX for Advanced & Expert Users

Track user commands

Hi, I have a unix server and I am concerned about the security on that server. I would like to be able to write a script that records all the commands that were typed at the command prompt before the user calls the 'history -c' command and deletes all the history. I was thinking about firing or... (7 Replies)
Discussion started by: mishkamima
7 Replies

9. Shell Programming and Scripting

keep track of every user

dear all , I m new to shell programming and I need your help. Actually i want to keep track of all the commands executed in a bash prompt of users , very much in same manner as it is displayed when we run "history" command. now the users are smart enough as they delete their history by... (6 Replies)
Discussion started by: xander
6 Replies

10. UNIX for Dummies Questions & Answers

Possible to track FTP user last login? Last and Finger don't track them.

Like the topic says, does anyone know if it is possible to check to see when an FTP only user has logged in? Because the shell is /bin/false and they are only using FTP to access the system doing a "finger" or "last" it says they have never logged in. Is there a way to see when ftp users log in... (1 Reply)
Discussion started by: LordJezo
1 Replies
Login or Register to Ask a Question