linux命令拦截
1. ~/.ucm/record_command.sh
#!/usr/bin/bash
record_cmd(){
printf "recording command:[$1]\n"
}
if [ $2 == 0 ];then
record_cmd "$1"
else
record_cmd "$1"
printf "will ignore exec [$1].\n";
fi
2. ~/.ucm/is_cmd_ban.sh
#!/usr/bin/bash if [[ "$1" == "aa"* ]];then echo 1; fi
3. 在.profile后面加上
#ucm linux command interceptor #set -T #shopt -s extdebug 如果执行的是禁用命令,则shopt -s extdebug,否则shopt -u extdebug trap 'a=0; if [[ $($HOME/.ucm/is_cmd_ban.sh "$BASH_COMMAND") == 1 ]]; then a=1; shopt -s extdebug; else shopt -u extdebug; fi; $HOME/.ucm/record_command.sh "$BASH_COMMAND" $a; false;' DEBUG