http://bbs.51cto.com/thread-594667-1.html  script使用注意事项
输入1:
[root@-shiyan rec]# cat record1
#!/bin/bash
#Filename:Record.sh dir=/tmp/rec
read -p "Please input the session filename: " filename
sesfile="$dir/$filename.session"
logfile="$dir/$filename.timing.log" if [ -e $sesfile ]
then
echo "$sesfile is Exsit,Creat session file fault!"
read -p "If you want to reload the file? [Y/N]: " flag
if [ "$flag" = "Y" ]
then
rm $sesfile $logfile
script -t > $logfile -a $sesfile
else
echo "Nothing to do!"
fi
else
script -t > $logfile -a $sesfile
fi 输入2:
[root@-shiyan rec]# cat replay1
#!/bin/bash
#Filename:Replay.sh
dir=/tmp/rec/
read -p "Please input the session filename: " filename
logfile="$dir$filename.timing.log"
sesfile="$dir$filename.session"
if [ -e $sesfile ]
then
scriptreplay $logfile $sesfile
echo
else
echo "$filename is NOT Exsit!"
fi 记录:
[root@-shiyan rec]# bash record1
Please input the session filename: uu
Script started, file is /tmp/rec/uu.session [root@-shiyan rec]# exit
exit
Script done, file is /tmp/rec/uu.session 回放:
[root@-shiyan rec]# bash replay1
Please input the session filename: uu
[root@-shiyan ~]# cat >>/etc/profile
source /root/jjj
[root@-shiyan ~]# ll /tmp/history/root/
total
-rw------- root root Feb : 192.168.2.84.history.20150212_104033
-rw------- root root Feb : 192.168.2.84.history.20150212_104036
-rw------- root root Feb : 192.168.2.84.history.20150212_104111
[root@-shiyan ~]# cat jjj
USER_IP=`who -m >/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
if [ "$USER_IP" = "" ]
then
USER_IP=`hostname`
fi
if [ ! -d /tmp/history ]
then
mkdir /tmp/history
chmod /tmp/history
fi
if [ ! -d /tmp/history/${LOGNAME} ]
then
mkdir /tmp/history/${LOGNAME}
chmod /tmp/history/${LOGNAME}
fi
export HISTSIZE=
DT=`date +"%Y%m%d_%H%M%S"`
export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP}.history.$DT"
chmod /tmp/history/${LOGNAME}/*history* 2>/dev/null

shell脚本实例-命令记录的更多相关文章

  1. 分享7个shell脚本实例--shell脚本练习必备

    概述 看多shell脚本实例自然就会有shell脚本的编写思路了,所以我一般比较推荐看脚本实例来练习shell脚本.下面分享几个shell脚本实例. 1.监测Nginx访问日志502情况,并做相应动作 ...

  2. linux 执行远程linux上的shell脚本或者命令以及scp 上传文件到ftp--免密码登陆

    场景:在linux A 上执行Linux B上的shell脚本和命令 步骤1.设置ssh免登陆 1.SSH无密码登录 # 本地服务器执行(A机器):生成密钥对 ssh-keygen -t dsa -P ...

  3. shell 脚本控制命令的执行顺序

    &&,||,(),{},& 五个符号的运用shell脚本执行命令的时候,有时候会依赖于前一个命令是否执行成功.而&&和||就是用来判断前一个命令执行效果的. 也 ...

  4. shell脚本实例,通向shell脚本大师的必经之路

    概述 读书百遍其义自见,shell脚本也是,只要例子看得多了,自然就知道怎么写了.这里主要整理了20几个例子,因为内容比较多,所以分了几次来做介绍了.下面的实例最好先自己思考怎么去实现,然后再看下实现 ...

  5. shell脚本实例-系统监控

    shell脚本监控网站并实现邮件.短信报警shell进程监控脚本(发送邮件报警)Shell脚本监控服务器在线状态和邮件报警的方法 http://www.jbxue.com/jb/shell/ 11. ...

  6. Shell 脚本常用命令

    Shell脚本是Linux开发工作中常用的工具,但是我一直没有找到一个适合自己的简明扼要的HandBook.在工作过程中整理了一下,贴在这里已备查看. 1           Shell中的特殊符号 ...

  7. 用 shell 脚本做命令行工具扩展

    问题的提出 公司开发机与远程服务器之间有严格的隔离策略,不能直接使用 ssh 登录,而必需通过跳板机.这样一来,本地与服务器之间的一些文件传输变得非常不便.经过咨询,运维教了我一招: $ nc -l ...

  8. Linux之Shell脚本计算命令行的所有和

    问题:设计一个Shell脚本:求命令行上所有整数和 Shell代码: 调用add.sh脚本结果:

  9. Makefile Shell 脚本;sed命令

    1. 在Makefile中想使用shell脚本,需要添加"@"符号,例如: @if [ -d xxx ]; then \                        //-d 判 ...

随机推荐

  1. JSP如何在servlet将一个数据模型对象传递给jsp页面

    在servlet把对象放到request里,然后jsp里直接通过request取值如 在servlet:(简写了)public void doGet(request,response){UserInf ...

  2. 怎么用sql语句查看某个字段值是否是唯一的

    select count(*) from table group by zd having count(*)>1 这是不唯一的过滤出来的语句

  3. python简介-copy

    首先python的老家https://www.python.org/ 原文http://www.runoob.com/python/python-intro.html Python 简介 Python ...

  4. UI 网络程序

    一,从网络地址获取一张图片 -(void)didClickDownLoad:(id)sender{    NSLog(@"%@",[NSDate date].description ...

  5. Ferry Loading II_贪心

    Description Before bridges were common, ferries were used to transport cars across rivers. River fer ...

  6. To and Fro

    Description Mo and Larry have devised a way of encrypting messages. They first decide secretly on th ...

  7. 转:label标签的特殊用法

    容易被忽略的label标签 原始作用 label标签是HTML原生的标签,其原始的作用参考这里 label 标签为 input 元素定义标注(标记). label 元素不会向用户呈现任何特殊效果.不过 ...

  8. JAVA 遍历文件夹下的所有文件

    JAVA 遍历文件夹下的所有文件(递归调用和非递归调用) 1.不使用递归的方法调用. public void traverseFolder1(String path) { int fileNum = ...

  9. C# 读取文本文档(转)

    1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出. byte[] byData = ...

  10. 382. Linked List Random Node

    Given a singly linked list, return a random node's value from the linked list. Each node must have t ...