作者: CyberSection 時間: 2019-4-15 10:21 標題: (已解決)想做一個script 做network restart 一問,THX
本帖最後由 CyberSection 於 2019-4-15 15:18 編輯
我想做一個script,當行 <cat /proc/net/arp> 'HW address' show <incomplete>, 之後行<sudo ifconfig eth0 down> and <sudo ifconfig eth0 up> ,請問我需要點做? THX
作者: cal22cal 時間: 2019-4-15 11:52
Put all this in a text file, say name as net.reset.sh
- #!/bin/bash
- cat /proc/net/arp
- ifconfig eth0 down && ifconfig eth0 up
- command line type:-
- chmod 700 net.reset.sh
- sudo chown root:root net.reset.sh
- sudo ./net.reset.sh
係咁上下
作者: CyberSection 時間: 2019-4-15 12:58
Put all this in a text file, say name as net.reset.shnet.reset.sh 要 sudo 先可以 del/edit
係咁上下 ...
cal22cal 發表於 2019-4-15 11:52
解決了,我閞頭以為要set $xx=incomplete 後set if $xx then 乜乜乜
原來只需cat /proc/net/arp | grep -q incomplete
then sudo ifconfig eth0 down
sudo ifconfig eth0 up
作者: cal22cal 時間: 2019-4-15 13:18
本帖最後由 cal22cal 於 2019-4-15 13:21 編輯
assign variable 就咁 xx=incomplete
直接 grep 就可以喇,唔洗 cat
- grep -iqs "incomplete" /proc/net/arp && { sudo ifconfig eth0 down && sduo ifconfig eth0 up; }

