Shell中使用plink工具实现远程批量关机
我的操作系统是centos6.4
操作系统:rhel 6.2 x86_64
下载并安装putty软件包,本人下载了putty-0.62-1.el6.rf.x86_64.rpm
下载地址如下:http://rpm.pbone.net/index.php3
1、远程主机IP列表文件
[root@localhost~]# vim server_list.txt192.168.0.13 192.168.0.12 192.168.0.11
2、远程主机要执行的操作的文件
[root@localhost~]# vim shutdown.txtshutdown -h now
3、远程关机自动化脚本
[root@localhost~]# vim remote_shutdown.shfor i in `cat server_list.txt` do plink -l root $i -pw redhat -m /shutdown.txt <<EOF y EOF done
4、脚本赋予执行权限x
[root@localhost~]# chmod a+x remote_shutdown.sh
5、脚本运行
[root@localhost~]# ./remote_shutdown.sh
注意:本人应用环境,所有主机root用户密码均为redhat,请根据实际环境调整,若无规律,可单条列出。
例如:
vim remote_shutdown.shplink -l root 192.168.0.12 -pw password1 -m /shutdown.txt plink -l jane 192.168.0.35 -pw password2 -m /shutdown.txt plink -l paul 192.168.0.77 -pw password3 -m /shutdown.txt plink -l root 192.168.0.19 -pw password4 -m /shutdown.txt (或 plink root@192.168.0.19 -pw password4 -m /shutdown.txt)
Shell脚本获取国内各大运营商网段脚本分享
亚太地区网络信息记录在这里,每天都有更新。http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest下面这个脚本将对这段文本进行编辑,输出国内几大运营
Shell脚本查看网卡实时流量
#!/bin/bashwhile["1"]doeth=$1RXpre=$(cat/proc/net/dev|grep$eth|tr:""|awk'{print$2}')TXpre=$(cat/proc/net/dev|grep$eth|tr:""|awk'{print$10}')sleep1RXnext=$(cat/proc/net/dev|grep$eth|tr:""|awk'{print$2}
Shell脚本实现上传zip压缩文件到FTP服务器
#/bin/bash#creator:lihuibin#date:2014-03-1016:45#desc:uploadfiletoftphosts="192.168.56.100"port=21user=testpass=testpwdwork_path="/var/www/cms"packname="publish"#hosts=$1#port=$2#user=$3#pass=$4#packn
编辑:一起学习网
标签:脚本,主机,操作系统,环境,文件