红联Linux门户
Linux帮助

[linux-tips]script帮助你截取屏幕信息

发布时间:2008-01-20 10:18:17来源:红联作者:HonxeInc
script是一个shell的内建命令,他的作用是为终端会话制作一个副本,把用户的输入/输出信息以文件的形式保存下来,详

以我的应用作个例子:

引用:
[root@asptest /]# script //开始捕获屏幕
Script started, file is typescript //输出文件是typescript ,也可以用script anyfilename,anyfilename就是输出文件.
[root@asptest /]# ls -l
total 3886
-rw-r--r-- 1 root root 61783 Sep 26 13:14 ha.d.tgz
-rwxr-xr-x 1 ha ha 3651714 Nov 9 10:35 heartbeat-2.1.2-2.src.rpm
drwxr-xr-x 11 root root 4096 Nov 23 11:30 home
-rw-r--r-- 1 root root 85 Oct 19 18:07 host.py
drwxr-xr-x 2 root root 4096 Aug 4 2005 initrd
-rw-r--r-- 1 root root 6880 Jan 16 10:48 lfscd-remastering-howto.txt
-rw-r--r-- 1 root root 0 Jan 19 18:42 typescript
drwxr-xr-x 16 root root 4096 Nov 24 00:02 usr
drwxr-xr-x 31 root root 4096 Nov 22 11:34 var
drwxr-xr-x 8 root root 4096 Sep 27 16:04 vz
[root@asptest /]# echo "$PWD"
/
[root@asptest /]# Script done, file is typescript (停止抓屏,可用exit,Ctrl+D,logout)
[root@asptest /]# ll
total 3890
drwxrwxrwt 10 root root 4096 Jan 19 18:40 tmp
-rw-r--r-- 1 root root 2546 Jan 19 18:42 typescript //输出的结果放在typescript中
drwxr-xr-x 16 root root 4096 Nov 24 00:02 usr
drwxr-xr-x 31 root root 4096 Nov 22 11:34 var
drwxr-xr-x 8 root root 4096 Sep 27 16:04 vz


script也可以用来指定文件保存输出结果(-a参数),可以不用交互性(-c)

引用:
[root@asptest /]# script -a test.log -c "cd /root/;ls;cd /tmp;pwd"
Script started, file is test.log
addftpuser.py hylafax-5.2.1-1.i386.rpm shell-scripts
anaconda-ks.cfg hylafax-5.2.1-1.src.rpm shutdown.sh
an_doregister.tar.gz hylafax-debuginfo-5.2.1-1.i386.rpm snmpd.conf
axel-1.0a-2.src.rpm install.log ssh.man
axel-1.0b.tar.gz install.log.syslog swatch.conf
bnx2-1.4.36b-dc4.1-all.img kernel-2.4.21-47.22AX.i686.rpm tcpdump.txt
boblog.sql libmd-0.3-i486-pc-linux-gnu tcp.txt
cacti libmd-0.3-i486-pc-linux-gnu.tar.bz2 test.log
dcop-strace.txt mbox vztmpl-asianux-2-2.0-2.i386.rpm
Desktop ntfs vztmpl-desktop-6-6.0-1.i386.rpm
gnupg-1.2.2.tar.gz openvz vztmpl-desktop-6-debuginfo-6.0-1.i386.rpm
--help.hwm proftpd_md5 welcome.msg
--help.pwd rainbowcrack-1.2-src xine-lib-1.1.2-2.el4.rf.i386.rpm
--help.pwi rainbowcrack-1.2-src.zip yum
/tmp
Script done, file is test.log
[root@asptest /]#
文章评论

共有 0 条评论