reset_right.sh

来自「对windows平台程序开发到Linux平台的程序开过渡做了说明」· Shell 代码 · 共 26 行

SH
26
字号
#!/bin/bash 
###判断是否带有参数
if [ '$1'=='];
  then
echo –e '\33[om reboot.sh filename  \n  filename if  a file which cantain  thi  ip  list you  want  to reboot .\n]';
exit;
fi
###显示提示信息并读取passwd
echo –e '\33 [lm\33[5mwarning : \33 [om this script will reboot following gameserver 'more 41'
 if you  confire to  do this ,please input the server password. Otherwise, press ^c to abort the  script .'
read –p $USER@server password: -s  passwd
echo –e "\n"

###读入IP地址给变量host,用expect控制登录过程
for host in 'more $1 | grep '^[1-9]''
do 
   expect –c '
   set timeout 30;
   spawn /usr/bin/ssh $host ls –1;
   expect {
\'*yes/no*'{send \'yes\r';
exp_continue }
        \'*password*\'{send \'$passwd\r\';}
expect eof ;'
done

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?