电脑技术学习

一个shell编写菜单

dn001


#zkcd 系统维护程序清单
while true
do
clear
echo "n"
echo "n ◆ 系 统 维 护 主 菜 单 ◆"
echo "n ==============================="
echo "
┏━━━━━━━━━━━━━━━━━━━━━━━┓"
echo " ┃
┃"
echo " ┃ 1. 查询用户 5. PING中心主机
┃"
echo " ┃
┃"
echo " ┃ 2. 杀 终 端 6. 显示时间
┃"
echo " ┃
┃"
echo " ┃ 3. 中止打印 7. 关 机
┃"
echo " ┃
┃"
echo " ┃ 4. 格式化软盘 0. 退 出
┃"
echo " ┃
┃"
echo " ┃ **********************
┃"
echo " ┃
┃"
echo "
┗━━━━━━━━━━━━━━━━━━━━━━━┛"
echo "n"
echo " 请 选 择(0?7):c"
read z
case $z in
1)clear
echo "n"
echo "n"
echo "用户名 终端号 登录时间"
echo "===================================="
who
tty=`tty |cut -f3 -d"/"`
echo "n"
echo "n 本机终端号为$tty"
read w
2) clear
echo "n"
echo "n 请输入终端号:c"
read t
pid=`ps -t $t |grep login | cut -f1,2,3 -d" "`
/tcb/bin/asroot kill -9 $pid
if [ "$?" != "0" ]
then
clear
echo "n"
echo "n"
echo "n $t 终 端 号 错 误 !"
read w
else
echo "n"
echo "n"
echo "n $t 终 端 已 退 出 !"
read w
fi

3) clear
lpd=`lpstat -u | cut -f1 -d" "`
cancel $lpd
clear
echo "n"
echo "n 打 印 请 求 已 删 除!"
read w
4)clear
echo "n"
echo "n 正在格式化软盘,请等侯......"
format /dev/rfd0135ds18
read w
5)clear
echo "n"
echo "n 正在 PING 中心主机..."
ping -c 1 132.122.1.1 >/dev/null 2>&1
if [ "$?" != "0" ]
then
clear
echo "n"
echo "n"
echo "n 网络通讯有问题,请和中心联系!"
read w
else
clear
echo "n"
echo "n 网 络 通 讯 正 常!"
read w
fi
6)clear
echo "n"
echo "n"
echo "n"
date '+ 今天是: %Y 年 %m 月 %d 日,星期 %w '
echo "n"
date '+ 现在的时间是:%T'
read w
7)clear
ps -ef | grep cibas | grep -v "grep"
if [ "$?" != "0" ]
then
/tcb/bin/asroot haltsys
else
echo "n"
echo "n"
echo "n 业务终端没有退出,不能关机!"
read w
fi
0)clear
exit
*)
esac
done
业务终端没有退出,不能关机!"
read w
fi
0)clear
exit
*)
esac
done

标签: