100 Scripts in 30 Days challenge: Script 8 — asciinema clone — Capture shell to log using cmd module

DailyPriyab
gopy
Published in
1 min readApr 17, 2017

I like asciinema and wanted to explore how it works at least the logging of the command part. Asciinema is a tool that records your terminal session and then saves in the cloud.

Also today I came across cmd module which helps to convert your python program as a command shell.

Details about my script:

  • It uses logging module of python to save the command output to file as well as showing it to the STDOUT.
  • I use the subprocess module to execute all the commands and capture their output through pipes
  • I use the cmd module to develope the commands shell and quit. “shell” command is used to execute a shell command. And “quit” is used to quit the session.

For any further details please contact me via twitter

Code is given below:

--

--

DailyPriyab
gopy
Editor for

Data Engineering | Data Governance | Azure | Spark | Python | Manager