By Franck Pachot

You are a speaker and like to show some demos. Which kind of demo do you do?

  • you script everything so that you just have to press ‘enter’ during the demo
  • you prepare everything in a text file and copy/paste during the demo
  • you type everything in live?
I don’t like the first one because it’s too basic. What do you do if you need to copy/paste a previous result in a future command? Playing with sqlplus variables can be too complex to show simple things. Or when you want to show locking behavior between 3 sessions?
I don’t like the second one because I don’t want to share my screen showing a ‘cheet sheet’ from which i copy/paste.

And I don’t like the third one because of:

And there is something else I want to avoid: I don’t want to sit behind my laptop. I like interactions with attendees during presentations. Especially during demos because this is where the ideas come out.

So today I did something different when presenting dbvisit replicate at SOUG. It was mostly demos: setup, start replication, show conflict resolution, etc.

I stayed stand up, running my demos with my remote presenter. Each click pasting the next command. I’ve sit and typed only to show non-prepared things, answering questions. Even when I need to copy/paste a previous result (the SCN given by the prepare table in order to run a refresh from SCN) the copy paste was scripted: search a pattern in the screen, copy and paste.

Franck Pachot presenting demo with tmux

People were surprised (which was my second goal of course) and asked me how to explain how I did that. I used tmux and I promised to explain in a blog post.

So here it is. I’ve made a short demo using the same technique.

multiple screens

Tmux is a terminal multiplexer, like screen which you probably use once you have been disconnected at the end of a recovery session. But tmux synchronize multiple windows. That means that I can have two windows for my session. One, with big fonts and full screen, goes to the beamer screen for the demo. And the other one is on my laptop, smaller because I want to see several windows at the same time.

That’s the first point. Instead of ‘duplicate’ my screen with Win-P, I keep the ‘extend’ screen that I have with powerpoint and have a different view from what I show.

multiple panes

The second point is that tmux can show different panes on the same window. Here, to show logical replication, I had one pane on the source, one on the target, and one small with swingbench running.

Here is a picture of that, when I’ve the dbvrep setup wizard on top, and verifying tnsnames.ora in the bottom:



The third point is that you can type into the tmux window either interactively, or from a tmux send-keys command. When I prepare my demos, I run them several times, adjusting what I want to show. So there I’ve just prepared the tmux send-keys lines so that I can run them one by one, or all of them in sequence automatically.
Here is the first part of my script which set the windows.
I have Cygwin, so I open windows with mintty but you can use whatever you want.
# I kill session if already exists 2>/dev/null
tmux kill-session -t demosession 2>/dev/null
# Then start a new session not attatched to the current terminal
tmux new-session -s demosession -d -n demo bash
# I use vi mode keys rather than emacs
tmux set-window-option -g mode-keys vi
# Then I will open 2 terminals attached to that session: one is full screen with
# big fonts, for the beamer, and one is smaller for my laptop to see that I do.
# I'm on cygwin and use 'mintty'. Each one attatches to the same session: what you
# type on one is seen in both.
# the one to show on the beamer is called 'DEMO'
mintty -p 700,100 -s 80,60 -o FontHeight=16 -t "DEMO $(date +%d.%m.%Y) - tmux - " tmux attach-session -t demosession &
# mine is called 'presenter'
mintty -p 800,0 -s 82,45 -o FontHeight=11 -t presenter tmux attach-session -t demosession &
sleep 1

Then I open the following script with vim where I have a macro that maps the ‘Page Down’ key (which is the one send by my remote presenter for powerpoint next slides) to execute the current line. So i can run each line one after each other, just clicking ‘next slide’ on my remote.
# Now ready to setup the panes I'll use
# I want a 10 lines pane at the bottom ( vertical split )
tmux split-window -t demosession:0.0 -v -l 10 bash
# And I split that pane (pane number 1 on window 0) to a 10 columns one on the right
tmux split-window -t demosession:0.1 -h -l 30 bash
# we can check the pane numbers
tmux display-panes
# now running in pane 1
tmux select-pane -t demosession:0.1
# show the date
tmux send-keys "date"
# enter 'enter'
tmux send-keys C-M
# well, there is another way...
tmux clock-mode -t .2
# now running in pane 0
tmux select-pane -t demosession:0.0
# now running a few commands in order to show copy/paste
tmux send-keys 'sqlplus sys/[email protected]/DB1 as sysdba'
tmux send-keys C-M
tmux send-keys 'create table DEMO (ts timestamp); '
tmux send-keys C-M
tmux send-keys 'insert into DEMO select current_timestamp ts from dual; '
tmux send-keys C-M
tmux send-keys 'commit; '
tmux send-keys C-M
tmux send-keys 'select current_scn from v$database; '
tmux send-keys C-M
tmux send-keys 'insert into DEMO select current_timestamp ts from dual; '
tmux send-keys C-M
tmux send-keys 'select * from DEMO; '
tmux send-keys C-M
tmux send-keys 'select * from DEMO as of scn '
# here I need to copy/paste the SCN. I enter copy mode
tmux copy-mode
# and search for 'CURRENT_SCN'and down 2 lines ( I'm in vi mode + space to select)
tmux send-key ? "CURRENT_SCN" c-M j j " " $
# 'enter' to copy
tmux send-key c-M
# then paste
tmux paste-buffer
# finish the statement
tmux send-key "; " c-M
# clean all
tmux send-keys 'drop table DEMO; '
tmux send-keys C-M
tmux send-keys '#exit '
tmux send-keys C-M
tmux kill-session -t demosession

You can refer to the tmux manual. I used only a few commands. The copy/paste is the more tricky one, but also the one with the better effect during the presentation.

Here is a screencast of running the above example:

It’s a short one but shows all the things I’ve used in my demos this morning.

Finally, you probably want to see my .vimrc file that maps the ‘Page Down’ (I don’t use PageDown in vi):


I check (with grep) that my command starts with tmux, and I search for the next tmux command to position the next line to run. This can probably be improved a lot but was sufficient for what I do.

Don’t forget that if anything goes wrong during the demo, you still can sit and have your commands that you can copy/paste in your presenter window. It’s synchronized on the demo window. And nobody can see you cheat sheet. I had an issue this morning because the window was smaller than I thought (beamer resolution) and the dbvrep console didn’t show all my tables. I just resized the pane manually and get back to my copy/paste. So knowing a few tmux interactive commands (type   control-b ?  for the help) is a good thing.

Finally, you have less stress because automation let you test it more times before. Just run it quickly (PageDown-PageDown-PageDown-…) the day before and you will see if your VM, your database, is still in the expected configuration. And during the preentation, you can go quicker (maybe I made it too fast the morning however) without wondering about typing mistakes, and have more time for interaction with attendees.