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. Palindrome Number ---- LeetCode 009

    Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negativ ...

  2. Chocolate_DP

    Description In 2100, ACM chocolate will be one of the favorite foods in the world. "Green, oran ...

  3. .NET概念:.NET程序编译和运行

    .NET概念:.NET程序编译和运行 分类: c#程序设计 2012-02-29 15:46 3001人阅读 评论(2) 收藏 举报 .net编译器语言microsoftassemblyvb.net ...

  4. 【转】高性能Javascript--脚本的无阻塞加载策略

    原文转自:http://blog.jobbole.com/78191/ Javascript在浏览器中的性能,可以说是前端开发者所要面对的最重要的可用性问题. 在Yahoo的Yslow23条规则当中, ...

  5. Struts2 中遇到的问题

    1. 警告: Could not find action or result: /Struts2Test/register.actionThere is no Action mapped for na ...

  6. 快速用springmvc搭建web应用-超越昨天的自己系列(10)

    Demo地址:http://pan.baidu.com/s/1sjttKWd 创建命令: mvn archetype:generate -DgroupId=com.witown.open.demo - ...

  7. java serializable深入了解

    声明:本文转自csdn论坛,原文地址为http://blog.csdn.net/zdw890412/article/details/7380069,对原作者表示感谢! 引言 将 Java 对象序列化为 ...

  8. FHS目录配置下,常见的几个问题及解答

    请说明/bin与/usr/bin目录所放置的执行文件有何不同之处? /bin主要放置在开机时,以及进入单人维护模式后还能够被使用的指令,至于/usr/bin则是大部分软件提供的指令放置处. 请说明/b ...

  9. js刷新当前页面

    a href="javascript:window.location.href=location.href"

  10. 学习使用:before和:after伪元素

    http://www.w3cplus.com/css3/learning-to-use-the-before-and-after-pseudo-elements-in-css.html