Last active
August 29, 2015 14:26
-
-
Save elijahc/2ecc6c13cc0b2d5ea88c to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env python | |
import json | |
import urllib2 | |
import os | |
import sys | |
import pexpect | |
import time | |
usr,pts = str(sys.argv[1]).split('.') | |
cat_facts = 'http://catfacts-api.appspot.com/api/facts' | |
request = urllib2.Request(cat_facts) | |
response = urllib2.urlopen(request) | |
msg = json.load(response) | |
cat_fact = str(msg['facts'][0]) | |
c = pexpect.spawn('write '+usr+' '+pts) | |
c.delaybeforesend = 0.5 | |
c.sendline('This factoid brought to you by cat_facts radio!') | |
c.sendline(str(cat_fact)) | |
time.sleep(2) | |
c.kill(1) |
This file contains hidden or 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
#!/bin/bash | |
args=("$@") | |
sessions=($(who | grep ${args[0]} | awk 'BEGIN{OFS="."} {print $1,$2}')) | |
for usr in "${sessions[@]}"; do | |
python /vol3/home/elijah/trl/cat_facts.py $usr | |
done | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
π