Wednesday, August 20, 2008

Script and Screen

At work we use script and screen for co-development and training.

If you want to work with others in a command line environment and don't use these yet, then you should definitely read this post.

Here's how we use it:

The first thing we do when we work together is we all ssh into the box we will work on.

Then we have the person driving start screen, a terminal multiplexor, and then script, a command logging tool.

Then everyone else logs into the drivers multiuser terminal session run by screen by typing screen -x, and can take over driving when needed. We all can read and write to the same set of terminals, and detach or reattach to the session as we come and go.

When we're done, we copy the drivers /home/driver/typescript file to someplace where we keep old training files like /backup/it/training/how_to_debug_that_thing.txt.

NOTE: screen can be used without script to do a similar job, and script can be used without screen to do a similar job. We just happen to use both.


Just type script to start it. It will start logging to your home directory in a file called typescript.

If you don't want to use screen, and just want to watch what someone else is doing, you can also try the -f option to flush output after each write. This is nice for telecooperation: One person does ‘mkfifo foo; script -f foo’ and another can supervise real-time
what is being done using ‘cat foo’.


Setting up and using GNU screen as a collaborative development environment (pay careful attention to the slashes).

Your user is peter, and you want to pair program with user mike.
1) Install GNU screen on the server and learn the ScreenBasics.
2) Drop the following two lines into /home/peter/.screenrc:
multiuser on
addacl mike
3) Execute the following two commands to allow mike to use your screen sessions:
chmod +s /usr/bin/screen
chmod 755 /var/run/screen
4) Peter is already logged into a screen session
5) Mike can type:
screen -x peter/
6) Peter and mike can now look a the same screen windows/terminals and share the same i/o

ScreenBasics - commands you will actually use, in the order you will probably use them

'screen'start screen session
'Ctrl-a c'create a new terminal
'Ctrl-a "'list the terminals in this session
(then hit the number of the terminal you want to switch to and hit enter)
'Ctrl-a Shift-a'rename a terminal
'Ctrl-a F'flush the screen when it gets screwed up
'Ctrl-a k'kill a terminal
'Ctrl-a d'detach from session
'screen -r're-attach to a screen session
'Ctrl-a S'make two terminal panes in the window
'Ctrl-a Shift \split the screen vertically
'Ctrl-a Tab'next pane in this window
'Ctrl-a Q'go back to one pane, current window

Other Screen Notes:

1) If you don't want to use script, you can get screen to record sessions as well. I think it's 'Ctrl-a H'.

2) The default screen key bindings collide with readline and emacs commands. I should look into remapping them someday.  Hit Ctrl-a-a to go to the beginning of a line.

3) Record and play back real-time textcasts with scriptreplay as follows:

script -t 2>timingfile testscriptfile
scriptreplay timingfile testscriptfile

Note: scriptreplay is a tiny perl script that was left out of most red-hat derived linux-util packages to date. You can get it from a debian derived distro or find it here.

4) If you are using MacOS, you are behind on every open source software application in existence.   You will have to compile and patch screen, script, emacs, and whatever else you use to get a modern functionality set.

5) You can access the scrollback buffer by hitting Ctrl-[.  After that point, the normal vi-like scrolling commands work i-j-k-l, Ctrl-u-b-d-f.  Hit esc to get out of the mode that allows you to scroll.


** The homepages for script and screen (for GNU/Linux users):

Script is in util-linux:


** Some of the better articles on screen:

Patching Screen for MacOS:

Tuesday, July 15, 2008

Silicon Valley Obscure Sports Quarterly Review - Q208

Welcome to the first issue of SVOSQR. In Q2 I thought I would report on "up-and-coming" obscure sports (read: I'm lazy and the sports on are not currently at the bleeding-edge of obscurity). links, pics and summaries follow.


Friggin Rocktackulous. About 20 people show up. Pleased to find that although I am now older, heavier, and weaker, I can still get that satisfying PWING! sound out of kicking the ball and deforming it into a lively ovoid before the other team catches it. Margaritas afterward in Willow Glen. Surprising amount of blood involved.

Ultimate Frisbee

Super friendly pickup game at Eagle Park in MV. Show up to learn ahead of time. Usually works best if you pick someone approximately your own body shape to cover. Couldn't tell if we were keeping score - could be that I was unaware of the scoring mechanism, but I prefer to think that it's really that casual of a game. They meet in Sunnyvale, too.


Silicon Valley is in desperate need of Dodgeball leadership!! Things are getting so bad that I have had to find pictures from other sports. The one silicon valley dodgeball meetup was held at Sky High, where they have a dodgeball room made out of trampolines (walls, ceilings, etc). Mixed group with lots of little kids and a few adults. It felt a little unfair to whale on the kids with a red rubber ball, but the realization that I could actually make them rotate on any one axis with a dodgeball strike kept my interest. Apparently, it's next to impossible to get old people to show up to a Dodgeball game. I tried to help and bring in a few folk, but could only drag one brave soul in with me. We were about half the group. Of course, now that the meetup group has gone inactive, there are dozens of interested people pledging to help. Will you be our Dodgeball leader (left picture - the guy who's winning), or will you be woefully unprepared for the next random strike (right picture - that is you).

A warning: There is not enough research to determine what obscure sports do to our bodies, exactly, but we do know that they fully condone the Bush adminstrations definition of torture. Any single obscure sport, picked up for the first time in maybe-ever, will find and cruelly torture muscles that you didn't know you had for weeks. Middle-aged humans are supposed to be dead, and therefore have not evolved to handle more than one attempt at obscure sports per month. Don't do it! But do let me know if you find an obscure sport in silicon valley that you would like me to try.

Saturday, April 26, 2008

Thinking Deeply about Concentrated Solar

I always have Polya's How to Solve It on my desk.

There is this one little part of it that I think everyone ignores, at first, in the "Devise a Plan" section:

"If you cannot solve the proposed problem ... Could you imagine ... A more general problem?"

Inside, when we read that, we think, "Are you friggin' kidding me? A bigger, more general problem? HaHa! Ged ouuuda here! I'm a-simplifyn'!" and quickly skip ahead.

I think Divide and Conquer is the first algorithm that comes to our minds. But it makes us think small - we miss data and cannot apply economies of scope.

It's not like we planned to do that.

I think many people initially plan to look at problems through the end of the process, trying to consider all players, evaluating their historical behaviour and setting up a migration path for them, coming to some solution that takes into account as much data as is useful. (Some people might call this "systemic thinking")

But we get myopic too quickly. We get tired. We find an interesting bit and get focused on the minutia, or start arguing whether a given solution to one part of the problem is feasible or not, and we can't give it up.

I was feeling this way about Global Warming. I got bogged down in studying how amazingly unsuccessful activists are at manipulating governments. Turns out, that wasn't one of the more interesting bits.

And now we return you to our previously scheduled feature on Concentrated Solar:

As Jamais Cascio puts it, the Earth will be just fine, it's humanity that is screwed.

Humanity won't make it without quickly shifting to new forms of power. However, I think we now have at least one reasonable roadmap. You can read all about how this technology is can solve our energy problem lots of places.
Who could implement this the most quickly?

Oil companies and our current power monopolies don't want to be replaced. Want to avoid a fight with them? Give them an advantage in concentrated solar. Just get them the hell out of the way and start them working on this problem. No time for a fight, here.

More specifically, the world has enough sunlit land and money to solve this problem 100 times over. The first set of goodies (We include one 100-year land lease and one suitable tech grant per set (but no batteries)) goes to our current oil and power conglomerats. That should be enough to please any stock holder, line any pocket, and guarantee implementation.

The next 99 sets go to entrepreneurs, which should also help.

You win, oil companies. No one has to die over this. Nice big carrot for you. Just get it done.

Of course, if they can't do it, well, first your land lease will get pulled if you can't get a few PetaWatts to market inside 10 years, but more importantly...if you thought all humanities carrot was big...even weilded in our death throes, that stick has got to be devastating. And, frankly, we never liked you anyway.

I'll write my congressman for you! Good luck!

Monday, January 07, 2008

Debunking the Technological Singularity

I have been arguing, at my local coffee shop, that
an empathy test needs to be developed for computer software

The Empathy Test would be unlike a Turing Test or a Voight-Kampf machine in that the purpose is not to determine whether a thinking machine is human. The purpose is to determine whether a thinking machine is a good match for human society.

Simply fooling a human into thinking that you feel his pain does not make you empathetic. I argue for testing a broad definition of empathy that is more useful to intelligent beings interacting in a civilized society. The pain of others need not be recognized by the subject. The pain must be felt as psychic stress in the subject. The program/subject, therefore, must be cognizant of it's own mortality, and pain must be a real threat to it's well being, as it is to us. Those guys in the asylum aren't exactly in endless loops, but they certainly have a few rogue processes. So the Empathy Test would be, in a sense, a destructive one that arguably mimics it's function in humans.

With luck, these empathy-equipped AIs will confirm the game-theoretic benefits of this feature and propogate it up to their designs. They will understand that this feature is for the preservation of lower races - an endangered species act, if you will. Alternately, it might just piss them off and subject us to summary disintegration. After all, how many programs have you killed today? How many lower species? On a macro scale, are we failing the empathy test?

In any case, I have found today that the point is moot! Recent historical research uncovers striking similarities between our past intellectual follies (SINGULARITARIANS MUST CLICK ON <-THAT LINK) and our current failed delusions of technological grandeur.

Clearly, I was entranced by the mental crack that is the singularity novel. For those of you with the same addiction, you can shoot up with this open content novel. Confirmed grade A stuff. But please, don't share dirty algorithms.