首页 | 资讯动态 | linux基础 | 系统管理 | 网络管理 | 编程开发 | linux数据库 | 服务器技术 | linux相关 | linux认证 | 嵌入式 | 下载中心 | 专题 | linux招聘 | 镜像站
OKLinux中文技术站
·设为首页
·加入收藏
·联系我们
系统管理: 中文环境 系统管理 桌面应用 内核技术 | Linux基础: 基础入门 安装配置 常用命令 经验技巧 软件应用 | Linux数据库: Mysql Postgre Oracle DB2 Sybase other
网络管理: 网络安全 网络应用 Linux服务器 环境配置 黑客安全 | 编程开发: PHP CC++ Python Perl Shell 嵌入式开发 java jsp | PHP技术: PHP基础 PHP技巧 PHP应用 PHP文摘
搜索中心 Linux招聘 Linux专题 Apache | Linux相关: 硬件相关 Linux解决方案 Linux认证 企业应用 其它Unix | 相关下载: 资料下载 参考手册 开发工具 服务器类 软路由 其它
 技术搜索:
会员中心 注册会员 高级搜索  
  → 当前位置:首页>网络管理>linux服务器>正文

Linux中通过script命令那个记录屏幕的输出

http://www.oklinux.cn  2008-10-16  OKLinux   会员收藏  游客收藏  【 】 
您查看的文章来源于http://www.oklinux.cn

我们用script来记录屏幕的输出,这个是在Linux的平台下使用的,Solaris和AIX中script命令没有-f选项。

-f选项的意思就是只有当缓冲区满后才能在另外一个终端显示前一次缓冲区满的内容。即使是异常退出也没有问题,仍然可以正常记录log,用命令script -f screen.log就可以了。

如果在第一个终端上使用mkfifo screen.log(一般不用这个命令)和命令script -f screen.log。在另外一个终端找到这个screen.log文件,用tail -f screen.log就会实时滚动输出你在第一个终端的输出。

如果没有-f就是只有当缓冲区满了后才能在另外一个终端显示前一次缓冲区满的内容。

第一个窗口:

[root@localhost ~]# script -f screen.log
Script started, file is screen.log
[root@localhost ~]# ls -ltr
total 33548
-rw-r--r-- 1 root root 15981 Jan 10 2008 server.met0
-rw-r--r-- 1 root root 9347 Mar 17 2008 install.log.syslog
-rw-r--r-- 1 root root 53792 Mar 17 2008 install.log
drwxr-xr-x 2 root root 4096 Jun 5 20:17 result
drwxr-xr-x 2 root root 4096 Jun 6 20:12 little
drwxr-xr-x 2 root root 4096 Jun 6 22:35 2little
drwxr-xr-x 2 root root 4096 Jun 6 23:04 big
-rw-r--r-- 1 root root 1079120 Jun 18 15:25 test.cap
drwxr-xr-x 5 root root 4096 Jun 30 12:43 Final
-rw-r--r-- 1 root root 805 Jul 2 20:15 Parser.h
-rw-r--r-- 1 root root 855 Jul 2 20:29 HttpDownloader.h
-rw-r--r-- 1 root root 2997 Jul 3 08:37 Parser.cpp
-rw-r--r-- 1 root root 2770 Jul 3 08:39 HttpDownloader.cpp
-rw-r--r-- 1 root root 32 Jul 28 16:21 HarmKeyWord.ini
-rw-r--r-- 1 root root 822 Jul 29 15:35 queue.cap
-rw-r--r-- 1 root root 3112 Oct 13 20:44 manscript
-rw-r--r-- 1 root root 79 Oct 13 20:47 screen.log
[root@localhost ~]# sdf
bash: sdf: command not found
[root@localhost ~]#
[root@localhost ~]# w
20:48:14 up 5 days, 4:29, 3 users, load average: 6.15, 2.60, 1.49
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 172.16.15.111 19:36 54:33 0.05s 0.05s -bash
root pts/3 172.16.13.134 20:44 35.00s 0.03s 0.00s tail -f screen.
root pts/5 172.16.13.134 20:28 0.00s 0.02s 0.00s script -f scree
[root@localhost ~]# exit
exit

Script done on Mon 13 Oct 2008 08:48:23 PM CST

[root@localhost ~]#

第二个窗口:

[root@localhost ~]# tail -f screen.log
Script started on Mon 13 Oct 2008 08:47:29 PM CST
[root@localhost ~]# ls -ltr
total 33548
-rw-r--r-- 1 root root 15981 Jan 10 2008 server.met0
-rw-r--r-- 1 root root 9347 Mar 17 2008 install.log.syslog
-rw-r--r-- 1 root root 53792 Mar 17 2008 install.log
drwxr-xr-x 2 root root 4096 Jun 5 20:17 result
drwxr-xr-x 2 root root 4096 Jun 6 20:12 little
drwxr-xr-x 2 root root 4096 Jun 6 22:35 2little
drwxr-xr-x 2 root root 4096 Jun 6 23:04 big
-rw-r--r-- 1 root root 1079120 Jun 18 15:25 test.cap
drwxr-xr-x 5 root root 4096 Jun 30 12:43 Final
-rw-r--r-- 1 root root 805 Jul 2 20:15 Parser.h
-rw-r--r-- 1 root root 855 Jul 2 20:29 HttpDownloader.h
-rw-r--r-- 1 root root 2997 Jul 3 08:37 Parser.cpp
-rw-r--r-- 1 root root 2770 Jul 3 08:39 HttpDownloader.cpp
-rw-r--r-- 1 root root 32 Jul 28 16:21 HarmKeyWord.ini
-rw-r--r-- 1 root root 822 Jul 29 15:35 queue.cap
-rw-r--r-- 1 root root 3112 Oct 13 20:44 manscript
-rw-r--r-- 1 root root 79 Oct 13 20:47 screen.log
[root@localhost ~]# sdf
bash: sdf: command not found
[root@localhost ~]#
[root@localhost ~]# w
20:48:14 up 5 days, 4:29, 3 users, load average: 6.15, 2.60, 1.49
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/1 172.16.15.111 19:36 54:33 0.05s 0.05s -bash
root pts/3 172.16.13.134 20:44 35.00s 0.03s 0.00s tail -f screen.
root pts/5 172.16.13.134 20:28 0.00s 0.02s 0.00s script -f scree
[root@localhost ~]# exit
exit

Script done on Mon 13 Oct 2008 08:48:23 PM CST

[root@localhost ~]#

通过这个方式,也可以用于教学当中,老师通过script命令记录操作日志,学员通过tail -f命令实时查看老师讲解情况。


上一篇:用2台Linux机器配置NAT穿越   下一篇:研究表明上网可以提高记忆力

收藏于收藏夹】 【评论】 【推荐】 【打印】 【关闭
相关文档
·用2台Linux机器配置NAT穿越
·Linux服务器随着使用时间的增长SSH登录越来越慢问题的
·Linux下生成spase文件
·VirtualBox中Linux和Windows建立桥接
·在Linux下使用ftp要注意文件夹权限的设置
·Linux下搭建samba服务器共享打印机
·Arch Linux下vsftpd的搭建
·Linux服务器使用tar与cron定期备份数据
·Linux下更改虚拟用后的默认FTP主目录
·Linux下tomcat服务的启动、关闭与错误跟踪
·Linux下Tomcat设置内存大小
·Linux下使用mutt和msmtp命令行发送邮件
·基于Ubuntu构建协作平台之服务器端篇——Trac
·SCU IPv6 for Linux
·Linux下Sendmail慢卡问题的解决
·Linux 主机清除 DNS Cache
发表评论
密码: 匿名评论
评论内容:

(不超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)
 
  最新文档
·用2台Linux机器配置NAT穿越
·Linux服务器随着使用时间的增长SSH登录
·Linux下生成spase文件
·VirtualBox中Linux和Windows建立桥接
·在Linux下使用ftp要注意文件夹权限的设
·Linux下搭建samba服务器共享打印机
·Arch Linux下vsftpd的搭建
·Linux服务器使用tar与cron定期备份数据
·Linux下更改虚拟用后的默认FTP主目录
·Linux下tomcat服务的启动、关闭与错误
·Linux下Tomcat设置内存大小
·Linux下使用mutt和msmtp命令行发送邮件
  阅读排行
·详解远程SHELL下安装配置RedHat ES 5的
·安装大型Linux集群(4):节点安装和 GPFS
·LVS集群学习笔记(NAT\DR\IP tunnel)
·Linux服务器存储空间巧妙管理
·安装大型Linux集群(1): 简介和硬件配置
·Linux系统下架设APACHE SVN服务器全过
·安装大型Linux集群(3):存储和共享文件
·RedHat Linux AS4 LAMP经典网站搭建实
·安装大型Linux集群(2):配置管理服务器
·Xen和虚拟化技术学习指南
·Linux系统邮件服务器常见错误报告列表
·linux下文件服务Vsftp详细介绍
·在Linux上用LVS搭建负载均衡的集群服务
·Linux 下配置vsftp虚拟用户总结
·Linux操作系统下SVN服务器的搭建详解
网摘收藏: