Chinaunix首页 | 论坛 | 博客
  • 博客访问: 36474
  • 博文数量: 7
  • 博客积分: 75
  • 博客等级: 民兵
  • 技术积分: 90
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-28 11:26
文章存档

2013年(4)

2012年(2)

2011年(1)

我的朋友

分类: LINUX

2012-10-05 10:48:12

用namp和ether-wake指令,自动生成一个远程唤醒局域网内所有主机的脚本
[root@localhost ~]# nmap -sP -n 192.168.20.* |awk '$1~/Host|MAC/ && $2!~/192.168.20.19/' |awk '{if($1~/Host/)print $2; else print $3}' |grep -v "A1:B3" |paste -d " " - - |awk '{print "ether-wake",$2,";","echo we have wakeuped ",$1}' > wakeup.sh
[root@localhost ~]# vi wakeup.sh
#!/bin/bash
#wakeup
i=1
while [ $i -le 10 ]
do
ether-wake 00:24:13:5B:20:4F ; echo we have wakeuped  192.168.20.1
ether-wake 00:1A:4D:6A:EC:A8 ; echo we have wakeuped  192.168.20.2
ether-wake 00:24:8C:AE:65:8E ; echo we have wakeuped  192.168.20.6
ether-wake 00:21:86:A1:D8:6A ; echo we have wakeuped  192.168.20.7
ether-wake 00:F1:F3:05:38:52 ; echo we have wakeuped  192.168.20.8
ether-wake 38:83:45:46:0E:AD ; echo we have wakeuped  192.168.20.9
ether-wake 00:24:BE:66:56:6D ; echo we have wakeuped  192.168.20.10
ether-wake 00:01:6C:A4:CC:90 ; echo we have wakeuped  192.168.20.12
ether-wake 00:17:31:68:3F:7C ; echo we have wakeuped  192.168.20.13
ether-wake 90:FB:A6:36:3D:3D ; echo we have wakeuped  192.168.20.14
ether-wake 00:1F:16:1C:78:98 ; echo we have wakeuped  192.168.20.16
ether-wake 00:17:31:68:3F:89 ; echo we have wakeuped  192.168.20.17
ether-wake 00:E0:D0:43:16:0B ; echo we have wakeuped  192.168.20.18
ether-wake 5C:26:0A:59:56:44 ; echo we have wakeuped  192.168.20.20
ether-wake 00:01:6C:1B:ED:C9 ; echo we have wakeuped  192.168.20.21
ether-wake 00:E0:D0:43:16:22 ; echo we have wakeuped  192.168.20.26
ether-wake 00:E0:4C:F7:A0:60 ; echo we have wakeuped  192.168.20.27
ether-wake 00:01:6C:A4:CC:5A ; echo we have wakeuped  192.168.20.37
ether-wake 00:E0:D0:22:3F:6D ; echo we have wakeuped  192.168.20.53
ether-wake 6C:F0:49:2E:09:49 ; echo we have wakeuped  192.168.20.62
ether-wake 00:E0:D0:22:3E:F2 ; echo we have wakeuped  192.168.20.64
ether-wake 00:B4:44:36:16:1B ; echo we have wakeuped  192.168.20.65
ether-wake 00:21:91:52:64:D6 ; echo we have wakeuped  192.168.20.66
ether-wake 00:E0:4C:04:78:09 ; echo we have wakeuped  192.168.20.67
ether-wake 00:17:31:68:40:02 ; echo we have wakeuped  192.168.20.79
ether-wake 00:19:21:82:FE:4A ; echo we have wakeuped  192.168.20.81
ether-wake 00:E0:4C:06:48:37 ; echo we have wakeuped  192.168.20.87
ether-wake 90:FB:A6:36:10:71 ; echo we have wakeuped  192.168.20.88
ether-wake 00:A1:A7:00:8D:07 ; echo we have wakeuped  192.168.20.91
ether-wake 00:0D:61:EC:45:47 ; echo we have wakeuped  192.168.20.94
ether-wake 00:11:11:1B:D9:54 ; echo we have wakeuped  192.168.20.102
ether-wake 00:E1:B1:B2:92:69 ; echo we have wakeuped  192.168.20.103
ether-wake 00:01:6C:14:B6:D4 ; echo we have wakeuped  192.168.20.104
ether-wake 00:E0:66:3C:A1:C7 ; echo we have wakeuped  192.168.20.107
ether-wake 00:0D:61:ED:15:AA ; echo we have wakeuped  192.168.20.111
ether-wake 00:01:6C:A4:CC:46 ; echo we have wakeuped  192.168.20.116
ether-wake 00:E0:66:3C:AF:42 ; echo we have wakeuped  192.168.20.125
ether-wake 00:17:31:BF:7E:E4 ; echo we have wakeuped  192.168.20.132
ether-wake 00:E3:73:39:07:0B ; echo we have wakeuped  192.168.20.143
ether-wake 00:E0:D0:43:16:13 ; echo we have wakeuped  192.168.20.147
ether-wake 00:26:18:B5:85:4A ; echo we have wakeuped  192.168.20.149
ether-wake 00:0A:E4:64:12:B2 ; echo we have wakeuped  192.168.20.150
ether-wake 00:E1:B1:B2:89:6F ; echo we have wakeuped  192.168.20.154
ether-wake 00:01:6C:14:AE:9F ; echo we have wakeuped  192.168.20.156
ether-wake 00:F1:F3:05:76:70 ; echo we have wakeuped  192.168.20.160
ether-wake 90:FB:A6:36:3D:95 ; echo we have wakeuped  192.168.20.161
ether-wake 00:E0:66:3C:A1:48 ; echo we have wakeuped  192.168.20.164
ether-wake 00:01:6C:15:0B:1B ; echo we have wakeuped  192.168.20.202
ether-wake 00:E0:4C:66:62:BB ; echo we have wakeuped  192.168.20.210
ether-wake 00:01:6C:A4:CA:98 ; echo we have wakeuped  192.168.20.211
ether-wake 00:1F:D0:0D:FE:78 ; echo we have wakeuped  192.168.20.230
ether-wake 00:1F:D0:0D:FD:BB ; echo we have wakeuped  192.168.20.231
ether-wake 00:30:18:A2:F7:58 ; echo we have wakeuped  192.168.20.233
ether-wake 00:01:6C:15:0A:A4 ; echo we have wakeuped  192.168.20.235
ether-wake 00:E1:B1:B2:92:68 ; echo we have wakeuped  192.168.20.252
sleep 5
let i++
done
[root@localhost ~]# chmod +x wakeup.sh
[root@localhost ~]# ./wakeup.sh
we have wakeuped 192.168.20.1
we have wakeuped 192.168.20.2
we have wakeuped 192.168.20.6
we have wakeuped 192.168.20.7
we have wakeuped 192.168.20.8
we have wakeuped 192.168.20.9
we have wakeuped 192.168.20.10
we have wakeuped 192.168.20.12
we have wakeuped 192.168.20.13
we have wakeuped 192.168.20.14
we have wakeuped 192.168.20.16
we have wakeuped 192.168.20.17
we have wakeuped 192.168.20.18
we have wakeuped 192.168.20.20
we have wakeuped 192.168.20.21
we have wakeuped 192.168.20.26
we have wakeuped 192.168.20.27
we have wakeuped 192.168.20.37
we have wakeuped 192.168.20.53
we have wakeuped 192.168.20.62
we have wakeuped 192.168.20.64
we have wakeuped 192.168.20.65
we have wakeuped 192.168.20.66
we have wakeuped 192.168.20.67
we have wakeuped 192.168.20.79
we have wakeuped 192.168.20.81
we have wakeuped 192.168.20.87
we have wakeuped 192.168.20.88
we have wakeuped 192.168.20.91
we have wakeuped 192.168.20.94
we have wakeuped 192.168.20.102
we have wakeuped 192.168.20.103
we have wakeuped 192.168.20.104
we have wakeuped 192.168.20.107
we have wakeuped 192.168.20.111
we have wakeuped 192.168.20.116
we have wakeuped 192.168.20.125
we have wakeuped 192.168.20.132
we have wakeuped 192.168.20.143
we have wakeuped 192.168.20.147
we have wakeuped 192.168.20.149
we have wakeuped 192.168.20.150
we have wakeuped 192.168.20.154
we have wakeuped 192.168.20.156
we have wakeuped 192.168.20.160
we have wakeuped 192.168.20.161
we have wakeuped 192.168.20.164
we have wakeuped 192.168.20.202
we have wakeuped 192.168.20.210
we have wakeuped 192.168.20.211
we have wakeuped 192.168.20.230
we have wakeuped 192.168.20.231
we have wakeuped 192.168.20.233
we have wakeuped 192.168.20.235
we have wakeuped 192.168.20.252
[root@localhost ~]# cp -p wakeup.sh /opt/
[root@localhost ~]# crontab -e
[root@localhost ~]# crontab -l
00 8 * * * /opt/wakeup.sh
每天早晨8:00整,准时唤醒办公室内所有主机。
阅读(1672) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~