linux主界面程序条,linux菜单式程序

用shell脚本编写有以下的功能:

Syste Manage

1.show the user    //显示登陆系统用户以及动作。

2.test the network //网络测试

3.show the TID   //显示进程信息

4.kill the peocess    //杀死进程

5.shoutdown the system   //关机

6. reboot the system     //重启

0.ecit     //退出程序

#! /bin/bash

#sh yan

while true

do

clear

tput cup 2 24

echo -n "system Manage"

tput cup 3 24

echo -n "*****************"

tput cup 4 24

echo -n "1.show the user"

tput cup 5 24

echo -n "2.tset the network"

tput cup 6 24

echo -n "3.show the PID"

tput cup 7 24

echo -n "4.kill the process"

tput cup 8 24

echo -n "5.shoutdown the system"

tput cup 9 24

echo -n "6.reboot the system"

tput cup 10 24

echo -n "0.exit"

tput cup 11 24

echo -n "*******************"

tput cup 12 24

echo -n "Please type in the option[0-6]:"

read AA

case $AA in

1) w

;;

2)tput cup 13 24

echo -n "qing shu ru ni yao ping de IP:"

read BB

(ping -c1 $BB >/dev/null 2>&1) && (tput cup 14 24;echo "OK!")||(tput cup 14 24;echo "Fail!")

;;

3)tput cup 13 24

echo -n "please type in the TID:"

read CC

ps -t $CC

;;

4)tput cup 13 24

echo -n "qing shu ru jing cheng hao :"

read DD

kill -9 $DD

;;

5)init 0

;;

6)init 6

;;

0)exit

;;

*)echo "cuo wu!"

;;

esac

read QQ

done

菜单式程序编写思路:

1)使用"tput cup"和"echo"命令,显示菜单。

2)调用case语句实现菜单各向功能。

3)使用“无条件循环”,使程序在每项功能实现后,返回主菜单。

4)在指定的位置(esac和done之间)加上read 变量 起停顿作用。

嘿嘿! 看看可以不,要灵活运用哦!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值