Chinaunix首页 | 论坛 | 博客
  • 博客访问: 612695
  • 博文数量: 104
  • 博客积分: 1968
  • 博客等级: 上尉
  • 技术积分: 1587
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-01 17:52
文章分类

全部博文(104)

文章存档

2013年(12)

2012年(50)

2011年(42)

分类:

2012-04-21 22:12:57

原文地址:菜单式shell脚本编写 作者:wizardzj

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 //退出程序

#(linux菜单式程序)

source code:

 

#! /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)在指定的位置(esacdone之间)加上read 变量 起停顿作用。
 
The authenticity of host '64.71.167.20 (64.71.167.20)' can't be established.
RSA key fingerprint is bf:fd:e4:52:fe:25:9c:72:f5:1f:49:77:cf:3b:85:79.
Are you sure you want to continue connecting (yes/no)?

ssh 连接时经常能碰到如上信息,如果一两台还可以手动输入,如果多了就麻烦
可以在/etc/ssh/ssh_config 中添加StrictHostKeyChecking no  就可以了
阅读(1871) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~