Hacker News new | ask | show | jobs
by yorwba 3045 days ago
If you just want to record, you could also try the script command, which comes preinstalled with most Unices. Asciinema's file format is more convenient for sharing and other niceties, but you probably won't have it installed everywhere. If you want to automatically record all SSH sessions on your server, script is the tool of choice.

I've also used it to fool programs that refuse to go into interactive mode when their input is not a TTY, but that's more of an abuse of script's purpose.

3 comments

I've used script to run shell aliases defined in .bashrc in a cronjob. Normally you would use bash -ic my_alias in crontab to run my_alias, but this gives a warning from bash:

bash: cannot set terminal process group (1661): Inappropriate ioctl for device bash: no job control in this shell

With script -qc 'bash -ic my_alias' /dev/null, the warning goes away! (Of course, the real solution would be to turn my_alias into a proper shell script, but this works in a pinch when you have old habits to abide by.)

Also see ttyrec:

http://0xcc.net/ttyrec/

I have been a big supporter of script command, infact i never understood the drive for asciinema and others like it written in various languages. I see asciinema as a dependency to be installed by users to record a session.
script was main inspiration for asciinema. I read its source code many times, and in the very first version it was used for recording. However on BSD based systems (and so on macOS) the shipped version of script doesn't support writing to a timing file, which pretty much killed it there.

Anyway, if you're only interested in replay inside a terminal, and you don't care about sharing the recordings on the web then reaching for script first is my recommendation. However, if we forget about the web part, there are still useful things for local workflow, like idle time optimization, pausing/stepping through recording and a single recording file instead of 2 (if you record timing info with script).