加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

learning shell display alert function

发布时间:2020-12-15 18:21:15 所属栏目:安全 来源:网络整理
导读:? 【 Purpose 】 ? ? ? ?Shell?print function base on err info wrn ext output level ? 【 Eevironment 】 ?????? Ubuntu 16.04 bash env ? 【 Procdeure 】 Source code: #!/bin/bash DEST=/tmp mkdir -p /tmp/debug display_alert() #------------------

?

Purpose

? ? ? ?Shell?print function base on err info wrn ext output level

?

Eevironment

?????? Ubuntu 16.04 bash env

?

Procdeure

  Source code:

#!/bin/bash
DEST=/tmp
mkdir -p /tmp/debug
display_alert()
#--------------------------------------------------------------------------------------------------------------------------------
# Let‘s have unique way of displaying alerts
#--------------------------------------------------------------------------------------------------------------------------------
{
# log function parameters to install.log
#[[ -n $DEST ]] && echo "Displaying message: [email?protected]" >> $DEST/debug/output.log

local tmp=""
[[ -n $2 ]] && tmp="[e[0;33m $2 x1B[0m]"

case $3 in
err)
echo -e "[e[0;31m error x1B[0m] $1 $tmp"
;;

wrn)
echo -e "[e[0;35m warn x1B[0m] $1 $tmp"
;;

ext)
echo -e "[e[0;32m o.k. x1B[0m] e[1;32m$1x1B[0m $tmp"
;;

info)
echo -e "[e[0;32m o.k. x1B[0m] $1 $tmp"
;;

*)
echo -e "[e[0;32m .... x1B[0m] $1 $tmp"
;;
esac
}
display_alert "List of local repos" "local" "err"
display_alert "List of local repos" "local" "wrn"
display_alert "List of local repos" "local" "ext"
display_alert "List of local repos" "local" "info"
display_alert "List of local repos" "local" "other"

?

?

  Test method:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读