2015. 2. 3. 11:56

내가 사용하고 있는 화면을 리눅스에 접속하고 있는 다른 사용자에게 공유하고 할 때 사용


간단한 사용법


#> who am i

AAAA    pts/0        2015-02-03 10:21 (1.1.1.1)


#> who

AAAA    pts/0        2015-02-03 10:21 (1.1.1.1)

BBBB    pts/1        2015-02-03 10:38 (2.2.2.2)


#> script /dev/pts/1

.

.

#> who

AAAA    pts/0        2015-02-03 10:21 (1.1.1.1)

BBBB    pts/1        2015-02-03 10:38 (2.2.2.2)

AAAA    pts/3        2015-02-03 10:55


.

.

#> exit


위의 명령어를 사용할 경우, AAAA가 사용하는 명령어 및 실행되고 있는 화면이 BBBB에게도 동일하게 보여진다.


이 경우, BBBB에서 다른 명령어 및 키보드를 입력할 경우 잠시 AAAA에게는 전달 되지 않는다.


AAAA가 script를 이용하여 공유하고 있을 경우, BBBB에서는 작업을 하지 않는 것이 좋다.


작업이 완료된 이후, AAAA에서 exit 명령어를 실행하면 script 작업이 완료된다.


이 외에 script 명령어를 이용하여 자신이 사용한 명령어의 화면은 특정 파일에 LOG를 남기는 것도 가능하다.


설명

 - Script 명령은 터미날에서 보여지는 모든 내용을 파일에 기록한다.  이것은 쉘에서의 사용자와 컴과의 작업 상태를 기록하고, 그것을 다시 살펴 보아야할 경우에 아주 유용하게 쓰인다.  또한 파이프 기능을 이용하여 다른 작업을 하고 있으면서이 기록 내용을 인쇄할 수도 있다.


script 옵션 정리

  1. 파일인자가 있으면, 그 파일에 모든 내용을 기록하고, 없으면, typescript 파일에 기록한다.
  2. a : 지정한 file 혹은 typescript라는 파일이 존재할 경우 파일을 새로 생성하여 저장하는 것이 아니라 추가되어 저장된다.
  3. c : script 실행시 실행될 명령어를 입력한다. 입력한 명령어가 종료되면 script도 종료된다.
  4. f : 사용하는 명령어들이 실시간으로 파일에 저장된다. -f 명령어를 사용하지 않으면 -t 옵션에 설정된 시간에 사용했던 명령어및 화면이 파일에 저장되나 -f 옵션을 사용하면 실시간으로 파일에 저장된다.
  5. q : 조용한 모드 실행 옵션으로, script 실행 시 및 종료 시에 상태 메세지 출력을 생략한다.
  6. t : 스크립트 실행 명령어 및 화면이 파일에 저장되는 시간을 설정한다. 미설정 시 기본값은 30초이다.


#> man script

NAME

script - make typescript of terminal session

SYNOPSIS

script [-a] [-c COMMAND] [-f] [-q] [-t] [file]

DESCRIPTION

Script makes a typescript 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 typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior con- tents. -c COMMAND Run the COMMAND rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. -f Flush output after each write. This is nice for telecooperation: One person does 'mkfifo foo; script -f foo' and another can supervise real-time what is being done using 'cat foo'. -q Be quiet. -t Output timing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indi- cates how many characters were output this time. This information can be used to replay typescripts with realistic typing and out- put delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the type- script file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal.

ENVIRONMENT

The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically).

SEE ALSO

csh(1) (for the history mechanism), scriptreplay(1).

HISTORY

The script command appeared in 3.0BSD.

BUGS

Script places everything in the log file, including linefeeds and 

     backspaces. This is not what the naive user expects.


Posted by Kimos