日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
詳解Linuxscript命令

Linux script命令script 是一個神奇命令,script 能夠將終端的會話過程錄制下來,然后使用 scriptreplay 就可以將其錄制的結果播放給他人觀看。script 的好處就在于你在終端中的所有操作、敲過的命令和打印出的結果它都可以原原本本地進行錄制??梢詰糜诮虒W、演示、審計,下面為大家分享一下script命令具體使用方法。

使用場景

1、調試會產(chǎn)生大量 log 的應用程序,并且需要保存到本地進行進一步分析;

2、與同事協(xié)同工作,自己將工作完成了一半,可以將操作過程記錄下來,發(fā)給同事,同事可以根據(jù)記錄接著工作;

3、讓人遠程協(xié)助你,擔心對方使壞,同時也可以留下案底,最好將他的操作記錄下來

如何使用 script 命令?

默認情況下,直接輸入 script 這個命令即可,它會在當前目錄自動創(chuàng)建一個 typescript 文件,之后你在此終端的所有操作都會被記錄在這個文件里。

記錄文件是一個文本文件,可以使用任意的文本工具打開查看。

如果要退出記錄,可以在終端里按快捷鍵 ctrl + D 或直接輸入 exit 。在退出 script 前,你會發(fā)現(xiàn),記錄文件大小為 0 Kb,當退出后,文件大小會變大。

[alvin@VM_0_16_centos test]$ script
Script started, file is typescript
[alvin@VM_0_16_centos test]$ echo hello
hello
[alvin@VM_0_16_centos test]$ ls
test1.py  test2  test2.cpp  test2.py  test3  test3.c  test.py  typescript  WeixinBot  wxpy  wxRobot
[alvin@VM_0_16_centos test]$ exit
exit
Script done, file is typescript

如果我們想要自己起個文件名,或者將文件放在其它位置,那么我們可以直接在 script 后面跟上文件名即可。

[alvin@VM_0_16_centos test]$ script ~/alvin-script
Script started, file is /home/alvin/alvin-script
[alvin@VM_0_16_centos test]$ ll
total 64
-rw-rw-r--  1 alvin alvin    21 Nov 10 09:40 test1.py
-rwxrwxr-x  1 alvin alvin 14074 Dec 31 07:35 test2
-rw-rw-r--  1 alvin alvin   403 Dec 31 07:35 test2.cpp
-rw-rw-r--  1 alvin alvin  2093 Nov 10 10:50 test2.py
-rwxrwxr-x  1 alvin alvin  8553 Jan  7 20:03 test3
-rw-rw-r--  1 alvin alvin    78 Jan  7 20:03 test3.c
-rw-rw-r--  1 alvin alvin    94 Nov  9 23:25 test.py
-rw-rw-r--  1 alvin alvin   489 Jan 11 12:07 typescript
drwxrwxr-x  6 alvin alvin  4096 Nov 10 11:19 WeixinBot
drwxrwxr-x  6 alvin alvin  4096 Nov 10 11:30 wxpy
drwxrwxr-x 11 alvin alvin  4096 Nov 10 11:34 wxRobot
[alvin@VM_0_16_centos test]$ echo hello
hello
[alvin@VM_0_16_centos test]$ exit
exit
Script done, file is /home/alvin/alvin-script

學會這兩個基本操作,可以應付很多場景下需要記錄終端的場景。

如何使用 script 與同事協(xié)作?

現(xiàn)在有一項工作,需要與同事一起協(xié)作,我完成一半,他完成另一半。

首先,我來做我的工作,用 script 記錄一下我的工作過程:

[alvin@VM_0_16_centos test]$ script cooperate-job
Script started, file is cooperate-job
[alvin@VM_0_16_centos test]$ echo this is alvin_s job
this is alvin_s job
[alvin@VM_0_16_centos test]$ ls
cooperate-job  test1.py  test2  test2.cpp  test2.py  test3  test3.c  test.py  typescript  WeixinBot  wxpy  wxRobot
[alvin@VM_0_16_centos test]$ exit
exit
Script done, file is cooperate-job

工作完成之后,將記錄文件發(fā)給同事,他可以使用文本工具打開,就可以知道你的進度了,然后接著你的進度干活。

如果他要接著在你的記錄文件里記錄他的操作的話,可以加一個 -a 選項,即 append 的縮寫。

[alvin@VM_0_16_centos test]$ script -a cooperate-job
Script started, file is cooperate-job
[alvin@VM_0_16_centos test]$ echo this is harry_s job
this is harry_s job
[alvin@VM_0_16_centos test]$ pwd
/home/alvin/test
[alvin@VM_0_16_centos test]$ exit
exit
Script done, file is cooperate-job

請他人遠程協(xié)助時,如何記錄他的操作過程?

讓他人登陸到自己的電腦,如果是熟人還好,是陌生人的話心里多少會有些不踏實。為了放心一下,我們還是偷偷記錄一下他的所作所為吧。

我們可以將 script 命令添加到 Shell 配置文件中,用戶一旦登錄進來,script 命令就自動啟動,并記錄操作者的所有操作過程。

實現(xiàn)這個目的,我們可以修改 .bash_profile 文件。

vim ~/.bash_profile

在最后一行,我們將 script 命令添加進去:

/usr/bin/script -qa your_path #補齊自己的路徑

然后保存,使用 source 或 . 命令使它生效。下次其它人登錄到系統(tǒng)時,script 就會自動運行,并將記錄文件保存在你所指定的位置。

在這里,-q 選項代表靜默記錄,對方將不知道你在后臺記錄。如果不使用這個選項,則他會收到這個提示:

Last login: Fri Jan 11 15:13:37 2019 from 119.33.28.6
Script started, file is /home/alvin/test/script-file  #提示
[alvin@VM_0_16_centos ~]$

本文標題:詳解Linuxscript命令
轉載注明:http://m.5511xx.com/article/dpoepjc.html