2010年(23)
分类: LINUX
2010-06-06 16:05:07
自己写一个小程序
System manage
************************
1. show the user
2. test the network
3. show the PID
4. kill the process
5. shutdown the system
6. reboot the system
0. exit
************************
Please type in the optin:_
(tput cap 上下距离行距/列)
答案:
#!/bin/bash
clear
tput cup 2 28(两行/28个子)
echo "System Manage"
tput cup 3 24
echo "******************"
tput cup 4 24
echo "1.show the user"
tput cup 5 24
echo "2.test the network"
tput cup 6 24
echo "3.show the PID"
tput cup 7 24
echo "4.kill the process"
tput cup 8 24
echo "5.shutdown the system"
tput cup 9 24
echo "6.reboot the system"
tput cup 10 24
echo "0.exit"
tput cup 11 24
echo "******************"
tput cup 12 24
echo -n "Please type in the option:"
read AA
case $AA in
1)w
;;
2)tput cup 13 24
echo -n "please type in the IP:"
read BB
if ping -c1 $BB >/dev/null 2>&1
then
tput cup 14 24
echo "chenggong"
else
tput cup 14 24
echo "shibai"
fi
;;
3)tput cup 13 24
echo -n "Please type in the terminal ID:"
read CC
ps -t $CC
;;
4)tput cup 13 24
echo -n "please type in the PID:"
read DD
kill -9 $DD
;;
5)init 0
;;
6)init 6
;;
0)exit
;;
*)tput cup 13 24
echo -n "input error,please retry!"
;;
esac
read AAA