5

When I am teaching a class, some students have problems following my CLI commands and would like to scroll back to be able to repeat the steps in their own speed. So I'd like to log all my inputs in realtime to an html-file or something similar, which I could server through a webserver. That way, the students could simply go to http://example.com/log#end and would always see the last entries.

I do know the multiuser mode of screen and have already used it to share sessions. However, I need to disable the write access of students and unfortunately, they are unable to scroll up, if I do so.

I also had a look at script, but it generates a terrible output, which - even when filtered through col -bp < logfile >> output.html is unreadable. Also, it does log the output as well, which complicates things and only dumps the logfile in unforeseeable intervals.

.bash_history could be used, but is only dumped to file when the session ends.

Any ideas?

Seth
  • 58,122
Lars
  • 455
  • I use Adobe Captivate when I want to give out instructions. (You can create some advanced guides, when you learn how to manage the application) – BD Bear Feb 10 '14 at 22:33
  • Do you want ALL keyboard input, or input specifically for bash? You said bash, but global keygrabbing is easier. Something to think about. – RobotHumans Feb 10 '14 at 22:40
  • Hm, might also be a possibility. In this specific case, I just need bash. – Lars Feb 12 '14 at 13:09
  • 1
    This blog entry have a extended description on how it can be done Perhaps the method of this answer could be used http://askubuntu.com/questions/80371/bash-history-handling-with-multiple-terminals – jhilmer Feb 10 '14 at 21:44
  • wow, very big solution. I might be able to adapt it to my needs and might use it in another scenario as well, thanks. I'll wait for a simpler solution before accepting it, though. ;) – Lars Feb 10 '14 at 21:47

1 Answers1

5

Use the built-in command history:

history -w hist.txt

will save the current history into file hist.txt.

If you have write permsiions to the appropriate directory you could do something like:

history -w /var/www/html/latest_history.txt

Then your students could access it in a browser: http://teachers.ip.address/latest_history.txt

sмurf
  • 4,680
  • User @Lars (who has insufficient rep to comment) comments: ----- This is a great answer. I ended up using the following to update it every few seconds while (true); do history -w /var/www/history.txt sleep 3 done – Jos Jul 22 '14 at 20:40