linux社区爱心援助Linux认证系列教程业界动态站务新闻公司招聘建议留言网址大全LPI专题CISCO专题
设为首页
加入收藏
管理团队
JSP  
JAVA  
PERL  
 您的位置:首页 > article > Linux入门与提高 > 使用与技巧 >
栏目导栏
资料搜索
热门文章
·VMware Tools的安装步骤
·应用Linux下两种中文输入法
·GRUB FOR DOS 引导安装LINUX和
·linux下BT软件介绍
·Linux中用ALSA驱动声卡流程详解
·Linux 170个常见问题的详细解答
·虚拟机软件vmware使用教程--使
·Linux操作系统Ifconfig命令详细
·什么是ISO文件?
·ffmpeg命令使用详解
·BabyLinux制作过程详解
·Linux挂接(mount)命令的使用方
·在Linux下制作工资表
·Linux必学的网络操作命令
·vmware下的fedora 6的vmware t
最新文章
·Linux新手要了解的十个知识点
·如何在Linux下实现定时器
·Linux桌面系统分区方案推荐
·Linux系统各常用目录简介及功能
·Puppy, CDLinux, DSL, Slitaz
·Ubuntu 8.04 升级到Ubuntu 8.1
·Linux系统信息查看命令大全
·linux下常用压缩文件解压方式
·ifconfig命令
·nohup命令详解
·Linux操作系统下限制root用户登
·Linux系统命令和使用技巧8则
·Linux操作系统下Tomcat自启动的
·ubuntu立方体桌面每个侧面显示
·测试Linux平台Inode使用情况的
Google
 
使用 script 記錄所執行的過程
[ 作者:Linux联盟收集  加入时间:2006-06-30 18:28:48  来自:Linux联盟收集 ]

Idea from Andrew Lee, thank you :)

相信很多人在寫 Linux 教學筆記或是除錯時,是先開啟終端機程式,再一行一行 copy/paste,現在有更好的方法,就是使用 script 這隻小巧的程式,可以把你所執行的過程完全忠實的完全記錄下來,如此就可以方便使用裡面的內容來做分析,以下為使用方法:

root # script
Script started, file is typescript
root # touch /misc/temp_file{1,2,3,4}-{a,b,c,d}
root # ls -l /misc/temp_file*
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file1-a
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file1-b
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file1-c
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file1-d
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file2-a
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file2-b
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file2-c
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file2-d
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file3-a
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file3-b
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file3-c
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file3-d
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file4-a
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file4-b
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file4-c
-rw-r--r-- 1 root root 0 4月 22 15:45 /misc/temp_file4-d
root# exit
Script done, file is typescript
root#

以上是我們所執行的過程,看好最上面有一個 "script" 指令,表示要開始記錄,而最後的 "exit" 代表結束錄製。最後會產生一個 typescript 的檔案,裡面就是所有的執行過程。

root # ls -l typescript
-rw-r--r-- 1 root root 1490 4月 22 15:46 typescript
root #

檔案內容:

root # cat typescript
root # ls -l /misc/temp_file*
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file1-a
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file1-b
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file1-c
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file1-d
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file2-a
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file2-b
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file2-c
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file2-d
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file3-a
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file3-b
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file3-c
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file3-d
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file4-a
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file4-b
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file4-c
-rw-r--r-- 1 root root 0 4月 22 15:53 /misc/temp_file4-d
root # exit
exit

Script done on Sat Apr 22 15:53:51 2006
root #

Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
无相关信息