[Discuss] Logging commands typed - quick and dirty

Mike Jackson michaelj at epcc.ed.ac.uk
Thu Jul 31 11:33:09 EDT 2014


Hi folks,

Occasionally the challenge of providing attendees with a log of the commands 
typed by the instructor has raised its head [1][2][3].

Last week, some attendees at Cranfield got a bit lost due to limited screen 
real estate caused by large fonts. Commands went off the screen when run. So I 
wanted to look again at providing a live log of the commands typed as a 
reminder for attendees and helpers (but not a replacement for the latter nor an 
excuse not to go at a suitable pace).

Why not just use the online lessons or instructor notes? These don't take into 
account me typing the wrong command by mistake, or the right command in the 
wrong location, and the attendees doing this too, and then requiring us to 
recover; or deviating from notes to answer attendee questions.

A quick and dirty solution is to use the bash PROMPT_COMMAND. Setting this to:

$ export PROMPT_COMMAND="history > history.txt"

dumps the history into history.txt upon every bash command (yes, it's 
inefficient but not brutally so - on the plus side it means the history
numbers are available and so provides a point of reference).

If you do your instructing on a host with web server space then just dump it 
there e.g.

$ export PROMPT_COMMAND="history > /home/michaelj/html/history.txt"

and give the attendees the URL e.g.:

http://www2.epcc.ed.ac.uk/~michaelj/history.txt

If using GitBash and Windows you can dump it into Google Drive or DropBox and 
make the file publicly available:

$ export PROMPT_COMMAND="history > /c/Users/mjj/Google\ 
Drive/Public/history.txt"

$ export PROMPT_COMMAND="history > /c/Users/mjj/Dropbox/Public/history.txt"

and give the attendees the associated URL. There is some lag due to the 
synching.

Like I said, quick and dirty. Use it or not.

cheers,
mike

PS I know that Trevor has done a script to render a typescript live [4] which 
handles both inputs and outputs and which serves the script at a URL, but here 
I just wanted the inputs, and not to have to run my own web server.

[1] [Tutors] HTML typescript for shell sessions 
http://lists.software-carpentry.org/pipermail/tutors_lists.software-carpentry.org/2013-January/000545.html
[2] [Discuss] Easy way to record and share your terminal
http://lists.software-carpentry.org/pipermail/discuss_lists.software-carpentry.org/2013-May/000515.html
[3] [Discuss] web-log for the shell
http://lists.software-carpentry.org/pipermail/discuss_lists.software-carpentry.org/2014-June/001799.html
[4]: http://blog.tremily.us/posts/script/script-publish.py

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.




More information about the Discuss mailing list