Using GNU Screen to perform a command line demo
A few weeks ago, I saw videos of developers at the Apple WWDC conference doing their presentations with a clipboard tool within OSX, which pastes snippets of code from a queue. Developers at the conference do not need to remember or refer to a document to provide an example. Their focus is only on the presentation.
Today, I gave a presentation to a group of developers showing off some capabilities of different tools from the command-line. I find it hard thinking about what I'm going to say in a public forum and thinking of command line arguments at the same time. My presenter hat comes off and I put on my engineering hat. One solution I came up with in Linux is to use the Screen command line tool to pass commands to a running Screen session (created with screen -S demo). This script runs in a different terminal on my laptop display, and all I have to do is press enter throughout the presentation.
The presentation today was a royal success. Partly due to this script.
Update: I was asked to explain the following code snippet. The code sends commands to a screen session called 'demo'. Created with the command above. It then loops through the command list and if the window is 0 pauses after each command to allow for explanation. If the window number is not zero it will execute the command without interaction in the screen window specified.
#!/usr/bin/env python
from subprocess import Popen
# set with -S on the screen commandline
screen_name = 'demo'
# window specifies the screen window to direct the command
commands = [
{
'window':0,
'command':'ls -l',
'post-command':'\n',
},
{
'window':0,
'command':'echo Hello World',
'post-command':'\n',
},
# direct this command to window 1
{
'window':1,
'command':'echo Hello from window 1',
'post-command':'\n',
},
]
def run_screen(screen_name, window, cmd):
Popen(['screen', '-S', screen_name, '-p', str(window), '-X', 'stuff',
cmd]).communicate()
for cmd in commands:
if cmd['window'] == 0:
print("(%(window)i) %(command)s" % cmd)
run_screen(screen_name, cmd['window'], cmd['command'])
if cmd['post-command']:
print("+ %s" % cmd['post-command'].replace('\n', '<cr>'))
raw_input('...waiting for keypress')
run_screen(screen_name, cmd['window'], cmd['post-command'])
print(".... talk about whats happening ....")
raw_input()
else:
run_screen(screen_name, cmd['window'], cmd['command'])
run_screen(screen_name, cmd['window'], cmd['post-command'])
Way too long…
It's been way too long since the last blog post. A couple months ago, Kristine and I went on a long overdue cruise vacation from Long Beach to Mexico. We had a blast!
Event-Json
I definitely need to come up with a better name. Event-JSON is a BSD licensed JSON-RPC 2.0 server written in C with libevent2. Please direct patches to the project page on github.
Source: http://github.com/rphillips/obelisk
[Updated: Link]
Lobster Tail and Crab Claw with Brandy/Sugar seasoned Pineapple

Lobster Tail and Crab Claw with Brandy/Sugar seasoned Pineapple,
originally uploaded by ryan.d.phillips.
BSD Man Pages with Ubiquity
Updated to use Parser2 for Ubiquity 0.5
The Mozilla Foundation in late 2008 created an experiment called Ubiquity for Firefox, which enables users to hit commands on their keyboards to do common tasks quickly and easily.
I should have wrote this plugin a long time ago, but today I got around to adding a BSD Man Pages plugin. Enjoy...







