Last active
June 9, 2018 10:20
-
-
Save komiyake/31a74597cdccb2e57c72e8b73f2e4bee to your computer and use it in GitHub Desktop.
buffaloルータのログをrsyslogでsyslogに流すようにして,Wi-Fiの接続をみて帰宅したかどうかを判断するようにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
$LOAD_PATH << File.dirname(__FILE__) | |
MAC_ADDRESS="" | |
def watch(file) | |
open(file) {|f| | |
f.seek(0, IO::SEEK_END) | |
loop { | |
line = f.read | |
if line.include?("associated successfully") and line.include?(MAC_ADDRESS) | |
#Light on | |
elsif line.include?("disassociated") and line.include?(MAC_ADDRESS) | |
#Light off | |
end | |
} | |
} | |
end | |
watch("/var/log/syslog") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment