- 论坛徽章:
- 0
|
在ubuntu/或者其他linux下运行,script screen.log,记录屏幕信息到screen.log里,一直记录到你exit为止,记录屏幕log的好方法...
- root@ubuntu2:/# script screen.log
- Script started, file is screen.log
- root@ubuntu2:/# ls -ltr
- total 76
- drwxr-xr-x 2 root root 4096 Jun 13 22:14 mnt
- drwx------ 2 root root 16384 Sep 10 10:08 lost+found
- lrwxrwxrwx 1 root root 11 Sep 10 10:08 cdrom -> media/cdrom
- drwxr-xr-x 4 root root 4096 Sep 10 10:08 media
- drwxr-xr-x 2 root root 4096 Sep 10 10:09 srv
- drwxr-xr-x 2 root root 4096 Sep 10 10:09 initrd
- lrwxrwxrwx 1 root root 29 Sep 10 10:13 vmlinuz -> boot/vmlinuz-2.6.24-19-server
- lrwxrwxrwx 1 root root 32 Sep 10 10:13 initrd.img -> boot/initrd.img-2.6.24-19-server
- drwxr-xr-x 2 root root 4096 Sep 10 10:42 bin
- drwxr-xr-x 13 root root 4096 Sep 10 10:42 lib
- drwxr-xr-x 2 root root 4096 Sep 10 10:44 sbin
- drwxr-xr-x 3 root root 4096 Sep 10 10:44 boot
- drwxr-xr-x 3 root root 4096 Sep 10 10:44 home
- drwxr-xr-x 2 root root 4096 Sep 10 11:54 root
- drwxr-xr-x 11 root root 4096 Sep 10 12:24 usr
- dr-xr-xr-x 73 root root 0 Sep 12 22:06 proc
- drwxr-xr-x 12 root root 0 Sep 12 22:06 sys
- drwxr-xr-x 10 root root 13700 Sep 12 22:06 dev
- drwxr-xr-x 15 root root 4096 Sep 17 14:45 var
- drwxr-xr-x 76 root root 4096 Sep 17 14:46 etc
- -rw-r--r-- 1 root root 0 Sep 17 15:09 #hello.sh#
- drwxrwxrwt 4 root root 4096 Sep 18 08:31 tmp
- drwxr-xr-x 4 root root 4096 Sep 23 21:40 opt
- -rw-r--r-- 1 root root 0 Sep 24 21:34 screen.log
- root@ubuntu2:/# exit
- exit
- Script done, file is screen.log
- root@ubuntu2:/# cat screen.log
- Script started on Wed Sep 24 21:34:52 2008
- root@ubuntu2:/# ls -ltr
- total 76
- drwxr-xr-x 2 root root 4096 Jun 13 22:14 mnt
- drwx------ 2 root root 16384 Sep 10 10:08 lost+found
- lrwxrwxrwx 1 root root 11 Sep 10 10:08 cdrom -> media/cdrom
- drwxr-xr-x 4 root root 4096 Sep 10 10:08 media
- drwxr-xr-x 2 root root 4096 Sep 10 10:09 srv
- drwxr-xr-x 2 root root 4096 Sep 10 10:09 initrd
- lrwxrwxrwx 1 root root 29 Sep 10 10:13 vmlinuz -> boot/vmlinuz-2.6.24-19-server
- lrwxrwxrwx 1 root root 32 Sep 10 10:13 initrd.img -> boot/initrd.img-2.6.24-19-server
- drwxr-xr-x 2 root root 4096 Sep 10 10:42 bin
- drwxr-xr-x 13 root root 4096 Sep 10 10:42 lib
- drwxr-xr-x 2 root root 4096 Sep 10 10:44 sbin
- drwxr-xr-x 3 root root 4096 Sep 10 10:44 boot
- drwxr-xr-x 3 root root 4096 Sep 10 10:44 home
- drwxr-xr-x 2 root root 4096 Sep 10 11:54 root
- drwxr-xr-x 11 root root 4096 Sep 10 12:24 usr
- dr-xr-xr-x 73 root root 0 Sep 12 22:06 proc
- drwxr-xr-x 12 root root 0 Sep 12 22:06 sys
- drwxr-xr-x 10 root root 13700 Sep 12 22:06 dev
- drwxr-xr-x 15 root root 4096 Sep 17 14:45 var
- drwxr-xr-x 76 root root 4096 Sep 17 14:46 etc
- -rw-r--r-- 1 root root 0 Sep 17 15:09 #hello.sh#
- drwxrwxrwt 4 root root 4096 Sep 18 08:31 tmp
- drwxr-xr-x 4 root root 4096 Sep 23 21:40 opt
- -rw-r--r-- 1 root root 0 Sep 24 21:34 screen.log
- root@ubuntu2:/# exit
- exit
- Script done on Wed Sep 24 21:35:04 2008
复制代码
已经找到了解决方法,异常退出也没有问题,仍然记录log,需要加上参数,script -f ido.log,如果在一个终端上使用mkfifo ido.log;script -f ido.log 然后在另一个终端登录,找到这个ido.log文件,你tail -f 就会滚动输出你操作的内容..这个非常方便...
关于mkfifo的使用,这里有一些使用方法,如果愿意深入研究这个指令,就man它...
下面是unbuntu 2.6.24-19-server 上的 script 手册...
- nova@unbuntu:~$ more manscript
- SCRIPT(1) BSD General Commands Manual SCRIPT(1)
- 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.
- AVAILABILITY
- The script command is part of the util-linux-ng package and is available
- from [url]ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.[/url]
- Linux July 30, 2000 Linux
复制代码
下面是视频,看不明白的,不愿意看的,直接看视频,省事...
更多内容请看...http://www.unix-center.net/bbs/v ... &extra=page%3D1
[ 本帖最后由 star33375249 于 2008-9-26 14:09 编辑 ] |
|