A collection of bot scripts to run from a Raspberry Pi.
- For this workshop we are using rPis (B and B+) with WIFI dongles.
- The OS we've installed is Raspbian (on 8Gb SD’s for the Raspberry Pi B and 16Gb SDxC for the Raspberry Pi B+)
- The OS and WIFI setup is covered here: http://www.iiclouds.org/20141117/basic-instructions-to-set-up-a-raspberry-pi/
- Once you have the Pi connected to the WIFI and know its IP address you can connect to it from another computer with SSH
- In terminal on your main computer type ssh pi@xxx.xxx.x.xxx, you'll be asked to enter the Pi's password
you're in!
- Install some software on the pi. The following are terminal commands for upgrading python, installing pip and then tywthon
sudo apt-get install python dev
sudo apt-get install python-pip
sudo pip install twython
you have python and libraries!
- Set up a new profile on twitter. Open an account, go to dev.twitter.com to create an app and get API keys.
- Download the twitterbot-example.py script and change it to have your new API keys.
- Open a new terminal window. We will use this to copy/paste over the twitterbot-example.py file
scp /Users/myname/Desktop/botexample.py pi@XX.XXX.XXX.XXX:~/
your bot script in on the Pi!
- The script will be in the Pis HOME directory. You may want to move it somewhere else such as /usr/local/bin/
- In your SSH terminal session go to HOME directory. Run the script with this line of code:
python twitterbot-example.py
the bot is running!
- To keep the bot running when you close SSH you may want to start it differently. The options are:
- install 'screen' (
sudo apt-get install screen
) then in SSH start the screen mode (screen
) then run the bot - Run with an ampersand (&) to keep script running 'headless' (
python twitterbot-example.py &
) *method not tested - Set up either a cron timer or init launch deamon *method not tested
stop the bot!
- An aggressive way is to SSH in and type
killall python
- alternatively
ps -A | grep python
, and you get the process id of this process. Thensudo kill <processid>