Skip to content

Instantly share code, notes, and snippets.

@j3tm0t0
Last active December 12, 2015 02:08
Show Gist options
  • Save j3tm0t0/4696333 to your computer and use it in GitHub Desktop.
Save j3tm0t0/4696333 to your computer and use it in GitHub Desktop.
scan MAC address and tweet
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
argvs = sys.argv
argc = len(argvs)
if (argc == 1):
print 'usage: %s text' % argvs[0]
quit()
import tweepy
auth = tweepy.OAuthHandler(secrets['consumer_key'],
secrets['consumer_secret'])
auth.set_access_token(secrets['access_token'],
secrets['access_secret'])
api = tweepy.API(auth)
api.update_status(argvs[1])
#!/bin/sh
BROADCAST=192.168.15.255
TARGETMAC=xx:xx:xx:xx:xx:xx
ping -c 2 $BROADCAST &> /dev/null
TARGETIP=`arp -a | grep $TARGETMAC | awk '{print $2}' | tr -d '[\(\)]'`
ping -c 2 $TARGETIP &> /dev/null
if arp -a | grep $TARGETMAC &> /dev/null
then
if [ ! -f "lock" ]
then
date "+%Y/%m/%d %H:%M" | tee lock
./arptweet.py "出社しました! `cat lock`"
fi
else
if [ -f "lock" ]
then
./arptweet.py "退社しました! `cat lock` - `date +%H:%M`"
rm lock
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment