Home » Archive for category 'Internet'

Internet Archive

Using boto for Amazon EC2

Posted May 20, 2013 By weetabix

Sorry for the month delay. I had things in “the real world” that I needed to deal with. I am back.


Today, I will go over Amazon a bit, and Boto, the Amazon Python SDK.

If you are unfamiliar with either Boto, or Amazon EC2, heres the tl; dr; version:

Boto is a Python2 API for Amazons AWS. I use it specifically to talk to the Elastic Cloud. It also happens to be the normal Amazon supported SDK. It can be ported to Python3.


For a longer version:

For Python2, the library can be installed as normal, from pip, etc. You can do it manually, but this would be the best method.

For Python3, you need to grab the py3kport branch, and run 2to3 after following the README and adjusting to suit your needs.

The documentation is the same for both.


After 2to3, there need to be a few more changes made:

Do vi /usr/local/lib/python3.2/dist-packages/boto/connection.py

Find uses of sock.sendall, such as sock.sendall("CONNECT %s HTTP/1.0\r\n" % host),

and change it to read sock.sendall(bytes("CONNECT %s HTTP/1.0\r\n" % host,'utf-8')).

i.e : sock.sendall("payload") becomes sock.sendall(bytes("payload",'utf-8'))

This corrects the last of the issues with 2to3, which happens to be coding strings for transmission over a socket.


Then, you can do things like:


#!/usr/bin/env python3
import boto.ec2
conn = boto.ec2.connect_to_region("us-east-1",
                                  aws_access_key_id='<FILL ME>',
                                  aws_secret_access_key='<FILL ME>')
reservations = conn.get_all_instances()
for x in reservations:
    print(x, x.instances)
    for y in x.instances:
        for key in y.tags:
            print(key, y.tags.get(key))

will give you a printout of all your instances, and the name you gave them, as well as any other tags.

The access keys can be retreived from your AWS account.

Until next week,


Be the first to comment

Terminal from anywhere

Posted March 4, 2013 By weetabix

Do you spend a lot of time in a terminal? I do… easily 80% of my “productive” time (e.g. not watching Stargate) is gazing into xfwm4-terminal.

Lets look at some scenarios: (I assume you want to ssh in more than once a week.)

Let’s imagine I’m away from home, at a buddy’s, and all he has is Windows. Simple right? Download PuTTY! (or bring it on a USB key. There is a portable version) Or wait, is there a better option? Yes, which brings me to my next scenario:

Suppose this Windows machine is at… say, your local electronics store, or  you simply cannot download a program for whatever reason?

Well, as long as you have Internet access to your server, you can use ShellInABox! This awesome server side software allows you a mostly functional ANSI/VT100 or Wyse 60 terminal.

The man page is fairly straightforward. You install the product to your webserver, and point a specific port to it, and set it to run as either a background service (I recommend this), or as an on-demand CGI (which uses less resources, but has to spin up. If your box is thrashing, this can take a while.)

Alright, you say… What about on my phone?

Well, if you have an iPhone, I don’t. Sorreh…

As for Android, there is a bevy of awesome software.  I currently use ConnectBot and irssi ConnectBot (since I chat on IRC with Irssi, I find it makes sense to have a terminal client that allows me to use the control keys within Irssi without butchering my usual xterm controls.)

Be the first to comment