zoukankan      html  css  js  c++  java
  • shell脚本实例-命令记录

    http://bbs.51cto.com/thread-594667-1.html  script使用注意事项
    输入1: [root@
    250-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 2> $logfile -a $sesfile else echo "Nothing to do!" fi else script -t 2> $logfile -a $sesfile fi 输入2: [root@250-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@250-shiyan rec]# bash record1 Please input the session filename: uu Script started, file is /tmp/rec/uu.session [root@250-shiyan rec]# exit exit Script done, file is /tmp/rec/uu.session 回放: [root@250-shiyan rec]# bash replay1 Please input the session filename: uu
    [root@250-shiyan ~]# cat >>/etc/profile
    source /root/jjj
    [root@250-shiyan ~]# ll /tmp/history/root/
    total 12
    -rw------- 1 root root   8 Feb 12 10:40 192.168.2.84.history.20150212_104033
    -rw------- 1 root root 124 Feb 12 10:41 192.168.2.84.history.20150212_104036
    -rw------- 1 root root  11 Feb 12 10:41 192.168.2.84.history.20150212_104111
    [root@250-shiyan ~]# cat jjj
    USER_IP=`who -m 2>/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 777 /tmp/history
    fi
    if [ ! -d /tmp/history/${LOGNAME} ]
    then
    mkdir /tmp/history/${LOGNAME}
    chmod 300 /tmp/history/${LOGNAME}
    fi
    export HISTSIZE=4096
    DT=`date +"%Y%m%d_%H%M%S"`
    export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP}.history.$DT"
    chmod 600 /tmp/history/${LOGNAME}/*history* 2>/dev/null
  • 相关阅读:
    java io
    java 线程
    java 引用
    spring面试合集
    jvm(6):JMM
    jvm(n):JVM面试
    jvm(5):类加载机制
    jvm(4):类文件结构
    C# UDP编程简介
    Facebook 对 Memcache 伸缩性的增强
  • 原文地址:https://www.cnblogs.com/createyuan/p/4287388.html
Copyright © 2011-2022 走看看