Skip to content

Instantly share code, notes, and snippets.

@komiyake
Last active June 9, 2018 10:20
Show Gist options
  • Save komiyake/31a74597cdccb2e57c72e8b73f2e4bee to your computer and use it in GitHub Desktop.
Save komiyake/31a74597cdccb2e57c72e8b73f2e4bee to your computer and use it in GitHub Desktop.
buffaloルータのログをrsyslogでsyslogに流すようにして,Wi-Fiの接続をみて帰宅したかどうかを判断するようにする
#!/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