Skip to content

Instantly share code, notes, and snippets.

@j3tm0t0 j3tm0t0/arptweet.py
Last active Dec 12, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.