How to record the terminal session - ttystudio tool

To record the terminal session using ttystudio tool

This article explains the installation of ttystudio tool. It records the Terminal activity and saves the output in GIF or PNG format. It contains an built-in gif and png writer.

Features

  • Recording a remote machine via ssh is possible.
  • Requires a terminal playback while writting an image.
  • Automatic conversion of gif or apng is supported.
  • Produces glitchy- free frames.
  • Can record frames even if nothing displayed on the screen.


To install the prerequisites

Run the following command to enable the epel repository.

[root@linuxhelp ~]# yum install epel-release -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: mirror.vastspace.net
Resolving Dependencies
-->  Running transaction check
--->  Package epel-release.noarch 0:7-6 will be installed
-->  Finished Dependency Resolution
.
.
.
Installed:
  epel-release.noarch 0:7-6                                                                                                      

Complete!

Execute the following command to install the nodejs and npm packages.

[root@linuxhelp ~]# yum install nodejs npm -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: epel.mirror.net.in
 * extras: centos.excellmedia.net
 * updates: mirror.vastspace.net
Resolving Dependencies
-->  Running transaction check
--->  Package nodejs.x86_64 0:0.10.42-4.el7 will be installed
--->  Package npm.noarch 0:1.3.6-5.el7 will be installed
-->  Processing Dependency: npm(npmlog) = 0.0.4 for package: npm-1.3.6-5.el7.noarch
-->  Processing Dependency: npm(npm-user-validate) = 0.0.3 for package: npm-1.3.6-5.el7.noarch
-->  Processing Dependency: npm(init-package-json) = 0.0.10 for package: npm-1.3.6-5.el7.noarch
-->  Processing Dependency: npm(editor) = 0.0.4 for package: npm-1.3.6-5.el7.noarch
.
.
.
  nodejs-rimraf.noarch 0:2.2.2-1.el7                                 nodejs-semver.noarch 0:2.1.0-3.el7                          
  nodejs-sha.noarch 0:1.2.1-1.el7                                    nodejs-sigmund.noarch 0:1.0.0-5.el7                         
  nodejs-slide.noarch 0:1.1.5-1.el7                                  nodejs-sntp.noarch 0:0.2.4-1.el7                            
  nodejs-tar.noarch 0:0.1.18-1.el7                                   nodejs-tunnel-agent.noarch 0:0.3.0-1.el7                    
  nodejs-uid-number.noarch 0:0.0.3-7.el7                             nodejs-which.noarch 0:1.0.5-8.el7                           
  openssl-devel.x86_64 1:1.0.1e-51.el7_2.5                           pcre-devel.x86_64 0:8.32-15.el7_2.1                         
  perl-srpm-macros.noarch 0:1-8.el7                                  redhat-rpm-config.noarch 0:9.1.0-68.el7.centos              
  v8.x86_64 1:3.14.5.10-17.el7                                       v8-devel.x86_64 1:3.14.5.10-17.el7                          
  zlib-devel.x86_64 0:1.2.7-15.el7                                  

Dependency Updated:
  e2fsprogs.x86_64 0:1.42.9-7.el7            e2fsprogs-libs.x86_64 0:1.42.9-7.el7     glibc.x86_64 0:2.17-106.el7_2.6            
  glibc-common.x86_64 0:2.17-106.el7_2.6     krb5-libs.x86_64 0:1.13.2-12.el7_2       libcom_err.x86_64 0:1.42.9-7.el7           
  libgcc.x86_64 0:4.8.5-4.el7                libgomp.x86_64 0:4.8.5-4.el7             libss.x86_64 0:1.42.9-7.el7                
  libstdc++.x86_64 0:4.8.5-4.el7             openssl.x86_64 1:1.0.1e-51.el7_2.5       openssl-libs.x86_64 1:1.0.1e-51.el7_2.5    
  pcre.x86_64 0:8.32-15.el7_2.1              zlib.x86_64 0:1.2.7-15.el7              

Complete!


To install ttystudio

Utilise the following command to install the ttystudio.

[root@linuxhelp ~]# npm -g install ttystudio
npm http GET https://registry.npmjs.org/ttystudio
npm http 200 https://registry.npmjs.org/ttystudio
npm http GET https://registry.npmjs.org/ttystudio/-/ttystudio-0.0.16.tgz
npm http 200 https://registry.npmjs.org/ttystudio/-/ttystudio-0.0.16.tgz
npm http GET https://registry.npmjs.org/term.js
npm http GET https://registry.npmjs.org/blessed
npm http GET https://registry.npmjs.org/pty.js
.
.
.
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/glob requires inherits@' 2'  but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/npmconf requires inherits@' ~2.0.0'  but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
npm WARN unmet dependency /usr/lib/node_modules/tar requires inherits@' 2'  but will load
npm WARN unmet dependency undefined,
npm WARN unmet dependency which is version undefined
ttystudio@0.0.16 /usr/lib/node_modules/ttystudio
??? term.js@0.0.7
??? blessed@0.1.81
??? pty.js@0.3.1 (extend@1.2.1, nan@2.3.5)

Start the ttystudio by using the following command.

[root@linuxhelp ~]# ttystudio linuxhelp.gif
[root@linuxhelp ~]# ping linuxhelp.com -c 5
PING linuxhelp.com (192.155.206.82) 56(84) bytes of data.
64 bytes from 52.ce.9bc0.ip4.static.sl-reverse.com (192.155.206.82): icmp_seq=1 ttl=56 time=254 ms
64 bytes from 52.ce.9bc0.ip4.static.sl-reverse.com (192.155.206.82): icmp_seq=2 ttl=56 time=242 ms
64 bytes from 52.ce.9bc0.ip4.static.sl-reverse.com (192.155.206.82): icmp_seq=3 ttl=56 time=247 ms
64 bytes from 52.ce.9bc0.ip4.static.sl-reverse.com (192.155.206.82): icmp_seq=4 ttl=56 time=255 ms
64 bytes from 52.ce.9bc0.ip4.static.sl-reverse.com (192.155.206.82): icmp_seq=5 ttl=56 time=243 ms

--- linuxhelp.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4033ms
rtt min/avg/max/mdev = 242.202/248.408/255.003/5.389 ms
[root@linuxhelp ~]# last root
root     pts/1        :0               Wed Jul 27 06:35   still logged in   
root     pts/1        :0               Wed Jul 27 05:40 - 05:41  (00:00)    
root     pts/0        :0               Wed Jul 27 05:40   still logged in   
root     pts/0        :0               Sun Jul 17 05:56 - 17:28  (-12:-27)  
root     :0           :0               Sun Jul 17 05:56   still logged in   
root     pts/0        :0               Sun Jul 17 05:40 - 05:45  (00:04)    
root     :0           :0               Sun Jul 17 05:40 - 05:45  (00:04)    
root     pts/0        :0               Sat Jul 16 12:25 - crash  (10:13)    
root     :0           :0               Sat Jul 16 12:25 - crash  (10:13)    
root     pts/0        :0               Sat Jul 16 12:20 - 12:24  (00:04)    
root     :0           :0               Sat Jul 16 12:20 - 12:24  (00:04)    
root     :0           :0               Sat Jul 16 10:50 - crash  (-5:-31)   

wtmp begins Sat Jul 16 03:48:54 2016

stop the recording by pressing CTRL+Q.

The ttystudio will compile the terminal activity in GIF format, and save the output in the current directory.

[root@linuxhelp ~]# ttystudio linuxhelp.gif
initializing writer
writing image
writing head
building gct (may take a while)
...........
gct is only 2 colors: using gct
writing netscape looping extension
writing GCE
writing frame 0 - 312 left
frame dimensions: 1032x406
writing frame 1 - 311 left
frame dimensions: 1x1
.
.
.
frame dimensions: 1x1
writing frame 310 - 2 left
frame dimensions: 1x1
writing frame 311 - 1 left
frame dimensions: 1x1
writing eof
stream: close
wrote image to linuxhelp.gif

Open the browser and navigate to the path where the recorded file is located.


Select the gif file and Double click to open.

FAQ
Q
what is the license of ttystudio tool?
A
Copyright (c) 2015, Christopher Jeffrey. (MIT License)

See LICENSE for more info.
Q
How to take multiple screenshot?
A
Run the following command,
# ttystudio o.gif --screenshot --screenshot-key C-p
Q
I was trying to install Asciinema, do you have any link for that?
A
You can follow this link, https://www.linuxhelp.com/how-to-install-asciinema-in-ubuntu-16-04/
Q
anyother way of recording terminal?
A
you can try this link also, https://www.linuxhelp.com/script-scriptreplay-commands-linux-examples/
Q
Very helpful tool, thank you
A
keep following us, www.linuxhelp.com