# Using script(1) to capture console output



## wblock@ (Aug 27, 2010)

script(1) can be used to capture console session output.  This is useful for later reference, like looking for what caused a port to fail to build.

Example:

```
# script /tmp/session.txt
# cd /usr/ports/www/links
# make
...
# exit

Script done, output file is /tmp/session.txt
```

Everything that was shown on the screen is captured in the output file /tmp/session.txt.


----------



## Caliante (Oct 10, 2010)

Excellent, this helped me already 

Thank you


----------



## jb_fvwm2 (Oct 11, 2010)

One can also use tee or sysutils/Tee similarly

```
man tee && man Tee
```
if the latter installed.  A third exists but is in sysutils/moreutils and I am unsure of how it is precisely useful in this case (The first post).


----------



## wblock@ (Nov 3, 2010)

jb_fvwm2 said:
			
		

> One can also use tee or sysutils/Tee similarly
> 
> ```
> man tee && man Tee
> ...



One difference between script(1) and tee(1) is that script captures everything, stdin, stderr, even the control characters typed or output.  tee(1) only captures stdin, not everything.  Of course, you can redirect, but script(1) is already there.  And it's in the base system.


----------



## Carpetsmoker (Nov 13, 2010)

As a minor note, the _rprompt_ option in tcsh screws up any output from script(1), so be sure to disable this.


----------



## eye (Nov 17, 2010)

Nah, only for those who view typescript files as plain text in dumb terminals. less(1) have -r and -R options to render terminal control sequences.

One can also record session with timestamps using -r option (cf. script(1) on NetBSD). It can later be played using -p option, e.g. to observe how user interacted with ncurses application such (nvi(1), tcsh(1)'s tab-completion, etc.). A few years back there were plenty of recorded howtos on youterm.com, mostly for radare, that could be viewed either via telnet or java applet. The feature is ported to FreeBSD in PR bin/114465.


----------

