Reputation: 4617
I was wondering if there is a command to "listen" to commands on Linux. What I mean, for every time a command is executed, for example sccs edit file, chmod +x file is executed
Upvotes: 1
Views: 620
Reputation: 25579
If this is just for your own use, you can create aliases or shell functions with the same name:
In bash:
alias ls="ls -l"
Then, whenever you do ls
, it actually does ls -l
(and any extra arguments are added after that).
Aliases are only useful to rename a command, and/or add a few initial parameters; you can't do anything more complicated. You can make the alias run a script, of course, and do anything you like that way.
Alternatively, you can create a shell function (put it in your .bashrc
file, for example):
Again, in bash:
function sccs () {
/usr/bin/sccs "$@"
status=$?
chmod +x "$1"
return $status
}
I've no idea what an sccs
command line looks like, so I expect you'd need to do something cleverer in there, but you get the idea, I hope.
Upvotes: 1