![]() |
VOOZH | about |
The 'script' command in Linux is a versatile tool that allows you to record all terminal activities, including inputs and outputs, making it a valuable resource for developers, system administrators, educators, and anyone who needs to document terminal sessions. This command captures everything displayed on your screen during the session, saving it in a file called a typescript. By default, if no filename is specified, the output is saved to a file named 'typescript'. The 'script' command is especially useful for logging command outputs, capturing installation processes, compiling open-source code, and creating educational demonstrations.
The 'script' command records a terminal session, creating a complete log of all inputs and outputs. This makes it a powerful tool for:
script [options] [file]To start a typescript without any argument. If no filename is given as argument, 'script' will automatically create a file namely 'typescript' in the home directory to save the recorded information.
Input:👁 Image
In order to stop the typescript, we just need to execute exit command and script will stop the capturing process. Since there's no filename given as argument, the script will automatically create a file namely typescript in the home directory to save the recorded information.
Output:
To start the typescript, run any random command and save it in a text file, let's say 'geeksforgeeks.txt'.
Input:
👁 Image
Output:
The output produced above is the content of the file 'geeksforgeeks.txt', created by 'script' command.
This option is used when we want to append the output, retaining the prior content of the file. The multiple contents get separated by adding a line that states the date and time of the script started.
Example:
Input:
👁 Image
Output:
👁 Image
This option is used when we want to run a particular command rather than interactive shell and get terminal information in the file given as argument or typescript by default. The script will automatically exit after successful execution.
Example: To get the typescript of 'cal' command.
Input:
👁 Image
Output:
👁 Image
Return the exit status of the child process, which is useful for scripting scenarios where the success or failure of commands needs to be tracked.
Flush the output after each write, making it useful for real-time monitoring. This is especially handy for collaborative work or live demonstrations.
This option allows default output file i.e. typescript to be hard or symbolic link.
Example: To capture terminal activity in a file let's say 'gfg2' that is stored in '/home/sc'.
Input:
👁 Image
Output:
👁 Image
This option does not display the notification stating that the script has started and quietly execute and exit the 'script' command.
👁 Image
This option allows user to capture the terminal activity step by step and appears like a video when the recorded file is executed with the help of 'scriptreplay' command.
Example: To capture terminal activity in a manual file, 'geeksforgeeks1'.
Input:
👁 Image
This option contains two data fields. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. Now let's check the output created using another command i.e. 'scriptreplay' as follow:
scriptreplay --timing=time_log geeksforgeeks1Output:👁 Image
Output version information and exit.
👁 Image
Display this help and exit.
👁 Image