Shell Scripting From Scratch, LFNW 2008

This year I gave two presentations af Linux Fest Northwest. The first was Network Protocols Illuminated, the second was Shell Scripting from Scratch.

The description of Shell Scripting From Scratch was as follows:

We'll develop, in real time, one shell script every five minutes to teach you the power and joy of shell programming. Topics will be taken from the audience as well as from some planned ahead of time. Learn the basics of debugging, looping, pipes, exit statuses, and other fun things.

The whole goal was to make this an interactive presentation, with lots of back and forth from the audience. Based on discussions with some GSLUGers before the conference, I thought my audience would be somewhat green, and was prepared to start at the beginning. To my pleasant suprise, when I described the shebang, I got rolled eyes ("Oh, no, we know that"), corrections ("isn't it actually called a hashpling/etc"), and polite requests ("Dude, step it up!").

The first audience request was for a way to make her Linux box become an alarm clock. We decided to make this a cron job that played a media file. Luckily Ubuntu comes with many .oggs, so I had something to work with. Sadly, none of them were embarassing or naughty, which would have been amusing.

We moved on from there, with requests from the audience, discussions of man pages and a few Linux daemons and tools along the way. I had a great time, and seems most participants did as well.

Embarassing Occurances

Embarrassing things that happened included:

  • I'd made a brand new Linux user, without any of my handy dandy scripts, in hopes I wouldn't be hand waving anything that's magically set up based on my home directory environment. Oh my, I'd forgotten how much I've added to my default setup (this was Ubuntu Dapper, so many things that I've been using are now the default, but not back then) like syntax highlighting, etc.

  • I did an adequate, but not stellar job managing certain attendees. If you were there, you know what I mean. Next time I'll bring a trebuchet.

  • Two people provided most of the ideas from which I coded. Would have liked more participation, but the ideas were great.

    Presentation

    I used script to make a log of the the terminal that I was using during the presentation. script will output each character that goes to the screen and, optionally, a timing file that lists how much time elapses between characters. Thus you are able to download the file below and watch exactly, typos and all, what went on overhead.

    Here are the available files:

    ContentTiming file (real time)Timing file (accelerated)
    shell-scripting shell-scripting.timing.realtime shell-scripting.timing

    Or, you can just download this handy-dandy tarball, bri-lfnw-presentations.tgz which contains all the presentation typescripts.

    To watch it, run one of the following commands:

    # To play the condensed version:
    $ scriptreplay scripting.timing.realtime scripting
    
    # To play the real-time version:
    $ scriptreplay scripting.timing scripting
    
    

    Make sure your screen is set to 24x80 so things look right when in vi, etc.

    I have a local copy of scriptreplay if you don't have it available on your system already.

    I am considering making a 'video' of this as well, and will post those here if I do so.

    The presentation was created using /usr/bin/script -t 2>timingfile, and the timing files modified with this quick and ugly perl hack:

    my($timing, $chars) = split;
    if ( $chars == 1 ) {
            $timing = "0.000500";
    } elsif ( $timing > 1 ) {
    	$timing = '1.000000';
    }
    print "$timing $chars\n";
    


    Everything herein is Copyright 2008, Bri Hatch of Onsight, Inc.