Results 1 to 9 of 9
Guys,I would like to know if there is any way to detect a command if it going to be executed in the shell?
Eg:
Cmd: sudo apt-get clean
I want ...
- 04-02-2010 #1
Detection of a command in shell
Guys,I would like to know if there is any way to detect a command if it going to be executed in the shell?
Eg:
Cmd: sudo apt-get clean
I want a C program to be called before this cmd is executed.
- 04-02-2010 #2Debian GNU/Linux -- You know you want it.
- 04-02-2010 #3
I think the implication here is to alias the apt-get command so that it kicks off a script that runs any number of commands before doing the actual intended operation. Or you could alias sudo I guess and then catch any command run with sudo.
Or are you asking is there a way to detect any arbitrary command, even without a "sudo" in front?
- 04-02-2010 #4
As per the need of the hour,I want my program to be called b4 sudo apt-get clean.
Thanks a lot for ur inputs.
I will work with it (aliasing).
- 04-02-2010 #5
How would I use alias to call my program when a command like "sudo apt-get autoclean" is gonna be executed??
Using alias ,i can create only some shortcuts only for commands,right??
- 04-02-2010 #6
Well, you "shortcut" sudo to your C program.
This program would check the first and second parameter. If they are "apt-get" and "autoclean", appropriate action is taken before "sudo apt-get autoclean" is literally invoked. Otherwise, sudo is executed in the C programm with whatever parameters there be.Debian GNU/Linux -- You know you want it.
- 04-09-2010 #7
GNU-Fan ,but your method works only in one terminal.
When I open up another i have to start the whole aliasing process.
Is there any better way to detect only the sudo apt-get clean command in ubuntu system??
- 04-09-2010 #8
Put the alias definitions in your ~/.bashrc file or ~/.bash_aliases (or other shell resource file as appropriate) so that it gets loaded automagically each time you start a new terminal window.
- 04-09-2010 #9


Reply With Quote