How to capture/record and replay linux terminal sessions using script and scriptreplay command in Ubuntu Linux

If you want to capture something like commands when you are installing some software, compiling some opensource codes or just want to see debug logs printed on the terminal by some program, there is command “script” which does all the work very efficiently for us. Just open a terminal, and type below command before you want things to be captured,

 $ script --timing=time.txt script.log 
Script started, file is script.log 
 devbee@laptop:~/wp$ pwd 
/home/devbee/wp 
devbee@laptop:~/wp$ cat /proc/version
Linux version 4.4.0-71-generic (buildd@lcy01-27) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #92-Ubuntu SMP Fri Mar 24 12:58:08 UTC 2017 
devbee@laptop:~/wp$ date
Sun Dec 31 09:48:05 IST 2017 
 devbee@laptop:~/wp$ time

real	0m0.000s
user	0m0.000s
sys	0m0.000s

Now, lets say, you are done with your recording, then type “exit” to stop script command running,

 $ exit
exit
Script done, file is script.log

Now to replay script recording using “scriptreplay” command, use below command,

 scriptreplay --timing=time.txt script.log 
Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply