Skip to content

Instantly share code, notes, and snippets.

@elijahc
Last active August 29, 2015 14:26
Show Gist options
  • Save elijahc/2ecc6c13cc0b2d5ea88c to your computer and use it in GitHub Desktop.
Save elijahc/2ecc6c13cc0b2d5ea88c to your computer and use it in GitHub Desktop.
#!/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)
#!/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
@speach
Copy link

speach commented Aug 7, 2015

πŸ‘

@speach
Copy link

speach commented Aug 7, 2015

🎱

@speach
Copy link

speach commented Aug 7, 2015

πŸ†

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment