View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Script

From LQWiki

(Redirected from Scripting language)
Jump to: navigation, search

This article is about the command script, for an explanation about the word script, see scripting.


The command script makes a transcript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the transcript file can be printed out later with lpr(1).

It is however recommended that script should not be used with tools such as vi that modify the terminal screen layout. As the output below shows, if you use vi or any similar tool that modifies the layout, the postscript file that is created contains a lot of grabage characters.

The junk characters are infact escape sequences that signify blank space, new line etc. For example, ^M is carriage return, ^[ is an escape character and ^H is backspace.

A vi example (history numbers added for clarity):

{21} $ script
Script started, file is typescript
{1} $ vi hello
{2} $ exit
exit
Script done, file is typescript
{22} $ 

The contents of the file typescript contain (line breaks added for clarity):

Script started on Mon Aug 23 08:39:34 2004
 {1} $ vi hello^M^M
^[)0^[7^[[?47h^[[1;65r^[[m^[[4l^[[?1h^[=^[[H^[[2J^[[1B~^[[1B^H~
^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[
1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B
^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~
^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[
1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B
^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~
^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[1B^H~^[[
1B^H~^[[1B^H~^[[1B^H~^[[H^[[64Bhello: new file: line 1^[[H
^[[64B^[[J^[[Hhello world^M^[[64BCopying file for recov
ery...^M^[[J^[[1;12H^M^[[64B:wq^Mhello: new file: 1 line
s, 12 characters^M^[[?1l^[>^[[J^[[H~^[[K^[[63B^Hhello: new 
 file: 1 lines, 12 characters.^M^[[1B^[[65;1H^[[2J^[[?4
7l^[8^M^[[?1l^[> {2} $ exit^M^M
exit^M

Script done on Mon Aug 23 08:39:43 2004

Note that if you were to view this file using cat, you wouldn't see any of these junk characters.



By default, the file script creates is called typescript. You can provide a filename to script, if you have to keep a regular log of the terminal session. script filename would create a file called filename in the current directory.

External links


Personal tools