Script command
When you work in a terminal or console, you may want to record everything you do in the terminal.
These records can be used as historical data to save everything that happens to the terminal.
SCIRPT is a command that can make a record of the output to the terminal. This is useful for those who want to actually record the terminal session. The record can be saved and printed later.
For example, you and some Linux administrators manage the same machine at the same time, or if you let someone remotely log on to your server, you might want to record what's going on in the terminal. To achieve this goal, you can use the script command.
For example:
=========================================================================================
[Email protected] ~]# script
Script started, file is typescript
[[email protected] ~]# LS/
Bin Dev iso lib64 mnt root shareinfo tmp
Boot etc layoutmanager.sh lost+found opt run srv usr
Content Home Lib media proc Sbin sys var
[Email protected] ~]# echo haha
haha
[[email protected] ~]# ls
Anaconda-ks.cfg lnmp_soft-4 Month 3rd. tar.gz Sougou Video Music
Bin nginx.sh typescript Picture Desktop
Crack_pycharm original-ks.cfg Public Documents
Initial-setup-ks.cfg rpmbuild Template Download
[email protected] ~]# cat typescript
[Email protected] ~]# ecit
Bash:ecit: Command not found ...
[[Email protected] ~]# exit
Exit
Script done, file is typescript
[email protected] ~]# cat typescript
Script started on May 09, 2018 Wednesday 13:19 02 seconds
[[email protected] ~]# LS/
Bin Dev iso lib64 mnt root shareinfo tmp
Boot etc layoutmanager.sh lost+found opt run srv usr
Content Home Lib media proc Sbin sys var
[Email protected] ~]# echo haha
haha
[[email protected] ~]# ls
Anaconda-ks.cfg lnmp_soft-4 Month 3rd. tar.gz Sougou Video Music
Bin nginx.sh typescript Picture Desktop
Crack_pycharm original-ks.cfg Public Documents
Initial-setup-ks.cfg rpmbuild Template Download
[email protected] ~]# cat typescript
[Email protected] ~]# ecit
Bash:ecit: Command not found ...
[[Email protected] ~]# exit
Exit
Script done on May 09, 2018 Wednesday 13:19 58 second
========================================================================================
Usage:
script [Options] [file ']
Options:
-A,--append append output
-F,--flush run flush (flush) after each write (write)
--force even if the output file is a link is still used
-Q,--quiet quiet mode
#############################################################################################
Mkfifo creates a FIFO (also known as a named pipe) with the specified file name.
"FIFO"是一种特殊的文件类型,它允许独立的进程通讯. 一个进程打开FIFO文件进行写操作,而另一个进程对之进行读操作, 然后数据便可以如同在shell或者其它地方常见的的匿名管道一样流线执行. 默认情况下,创建的FIFO的模式为0666(‘a+rw‘)减去umask中设置的位.
=========================================================================================
Mkfifo with script------screen sharing
On the machine where you want to share the operation:
Mkfifo xxx (Create a named pipe, XXX is the file name created)
script-f XXX (Record the screen operation in the created special file XXX)
To view the shared machine:
Use SSH to remote to the shared host, and then use the Cat command to view the named pipe files created on the shared host:
Cat xxx
#########################################################################################
In addition
Mknod Mknod-Create a block-specific or character-specific file, or you can use it to establish a named pipe.
Mknod [options] name {BC} major minor
Mknod [options] name P
Linux uses script and MKFIFO commands for screen sharing,,,