循环拷贝测试USB的脚本
来源:互联网 发布:淘宝饰品店名字 编辑:程序博客网 时间:2024/05/22 19:31
前段时间,进行USB拷贝方面的测试,积累了几个测试脚本,也可以进行磁盘间的拷贝,放在这里备份。
主要实现功能:
从一个存储设备拷贝数据到另一个位置,并比较两次拷贝的数据是否一致,并判断系统是否有错误产生;
采用3种方法,主要是为了直观反映拷贝情况。
说明见方法3。
1、使用rsync命令进行拷贝,以百分比提示,并动态显示文件大小:
#!/bin/bash DEST_PATH=$1 #The dst path; Usually a /media/U-disk or /homeSOUR_PATH=$2 #The src file path; i.e the dir of testfile.tar.gz FILE=$3 #The tar file which will be copy#eg:run like this: sh -x cp_usb_md5.sh /media/teclast/ /home/loongson/ testdir.tar.gzloop=0while true; doecho begin copy #curl -# file:/$SOUR_PATH$FILE -o $DEST_PATH$FILE #One method use curlrsync -av --progress $SOUR_PATH$FILE $DEST_PATH #Second method use rsyncdmesg | grep "Buffer I/O error"if [ $? -eq 0 ];then echo "error is happen" exitelse echo compare md5sum A=`md5sum $SOUR_PATH$FILE|awk -F ' ' '{print $1}'` B=`md5sum $DEST_PATH$FILE|awk -F ' ' '{print $1}'` echo $A >> md5A.txt echo $B >> md5B.txt test $A == $B && echo "md5sum1 = md5sum2"||echo "error" echo begin rm rm -rf $DEST_PATH$FILE echo "loop $((loop++))" sleep 3fi#echo 3 >/proc/sys/vm/drop_cachesdone
2、使用curl命令进行拷贝,有进度条提示:
#!/bin/bash DEST_PATH=$1 #The dst path; Usually a /media/U-disk or /homeSOUR_PATH=$2 #The src file path; i.e the dir of testfile.tar.gz FILE=$3 #The tar file which will be copy#eg:run like this: sh -x curl_usb_md5.sh /media/teclast/testdir.tar.gz /home/loongson/testdir.tar.gzloop=0while true; doecho begin copy curl -# file:$SOUR_PATH$FILE -o $DEST_PATH$FILE #One method use curldmesg | grep "Buffer I/O error"if [ $? -eq 0 ];then echo "error is happen" exitelse echo compare md5sum A=`md5sum $SOUR_PATH$FILE|awk -F ' ' '{print $1}'` B=`md5sum $DEST_PATH$FILE|awk -F ' ' '{print $1}'` echo $A >> md5A.txt echo $B >> md5B.txt test $A == $B && echo "md5sum1 = md5sum2"||echo "error" echo begin rm rm -rf $DEST_PATH$FILE echo "loop $((loop++))" sleep 3fi#echo 3 >/proc/sys/vm/drop_cachesdone
3、使用命令进行拷贝,提示文件进度:
#!/bin/bash DEST_PATH=$1 #The dst path; Usually a /media/U-disk or /homeSOUR_PATH=$2 #The src file path; i.e the dir of testfile.tar.gz FILE=$3 #The tar file which will be copy #设置输入变量#eg:run like this: sh -x cp_usb_md5.sh /media/teclast/ /home/loongson/ testdir.tar.gzloop=0 #初始化循环次数while true; do #无限循环echo begin copy cp -rv $SOUR_PATH$FILE $DEST_PATH #third method use cpdmesg | grep "error" #查看是否有报错情况if [ $? -eq 0 ]; #判断执行返回值then echo "error is happen" exit #停止测试else echo compare md5sum #提取两边数据的md5值,判断是否一致 A=`md5sum $SOUR_PATH$FILE|awk -F ' ' '{print $1}'` #其实可以只做一次的 B=`md5sum $DEST_PATH$FILE|awk -F ' ' '{print $1}'` echo $A >> md5A.txt echo $B >> md5B.txt test $A == $B && echo "md5sum1 = md5sum2"||echo "error" echo begin rm rm -rf $DEST_PATH$FILE #删除文件,并加一 echo "loop $((loop++))" sleep 3fi#echo 3 >/proc/sys/vm/drop_caches #清空缓存done
- 循环拷贝测试USB的脚本
- (C#)单链表和循环单链表的深浅拷贝及其测试
- 带USB加密锁的压力测试脚本程序编写
- bash脚本循环测试sample
- 循环队列的测试
- 写一个循环启动app的bat脚本辅助monkey测试
- java中对数组的循环拷贝
- js深拷贝,for循环的用法
- shell 脚本写的拷贝大文件显示拷贝百分比
- shell脚本循环执行任务的脚本
- shell脚本的循环 例子
- shell的脚本循环处理
- 拷贝代码以及其行号的脚本
- 测试脚本的独立性
- sq测试的脚本
- 测试脚本的编写
- Windows7-USB-DVD-tool提示不能拷贝文件的处理
- 关于浅拷贝和深拷贝的简单应用测试
- http://poj.org/problem?id=3264
- org.apache.jasper.compiler.TldLocationsCache tldScanJar No TLD files were fou
- Android ndk 之二
- 线程,进程
- 一些常用的Intent及intent-filter的信息
- 循环拷贝测试USB的脚本
- 维修hp500宽幅彩色打印机
- oracle数据库的启动与关闭
- JAVA调用系统命令或可执行程序
- ubuntu的账户密码算法
- 网络编程中Nagle算法和Delayed ACK的测试(转)
- 遍历hashmap、hashset的方式总结
- Eclipse下UML插件及安装<转>
- ubuntu 12.04 完美安装sublime text2