1 #!/bin/bash 2 path="/sys/devices/platform/soc/fd880000.i2c-pld/i2c-0/i2c-4/i2c-15/15-0060" 3 arry=(module_interrupt module_present)#定义数组元素,可以扩展为多个,或仅为一个元素 4 5 for f_log in ${arry[*]} 6 do 7 rm -rf $f_log*.log 8 done 9 10 11 for i in {1..32} 12 do 13 14 echo "#####################Start test port["$i"]##########################" 15 echo "#cat $path/port"$i"_"${arry[0]}"" | tee -a 2>&1 ${arry[0]}.log 16 cat $path/port"$i"_"${arry[0]}" | tee -a 2>&1 ${arry[0]}.log 17 18 echo "#cat $path/port"$i"_"${arry[1]}"" | tee -a 2>&1 ${arry[1]}.log 19 cat $path/port"$i"_"${arry[1]}" | tee -a 2>&1 ${arry[1]}.log 20 21 sleep 1 22 #提示字符串,拔出optical or loopback module,端口号以红颜色显示$i,31m 23 read -t 30 -p "`echo -e "please unplug optical/loopback module \033[31m ["$i"] \033[0m"`...after that.Please press "Enter" key to continun": 24 sleep 1 25 echo "#cat $path/port"$i"_"${arry[0]}"" | tee -a 2>&1 ${arry[0]}.log 26 cat $path/port"$i"_"${arry[0]}" | tee -a 2>&1 ${arry[0]}.log 27 28 echo "#cat $path/port"$i"_"${arry[1]}"" | tee -a 2>&1 ${arry[1]}.log 29 cat $path/port"$i"_"${arry[1]}" | tee -a 2>&1 ${arry[1]}.log 30 31 sleep 1 32 #提示字符串,插回optical or loopback module,端口号以红颜色显示$i,31m 33 read -t 30 -p "`echo -e "please plug back optical/loopback module.\033[31m ["$i"] \033[0m"`..after that.Please press "Enter" key to continun" 34 sleep 1 35 echo "#cat $path/port"$i"_"${arry[0]}"" | tee -a 2>&1 ${arry[0]}.log 36 cat $path/port"$i"_"${arry[0]}" | tee -a 2>&1 ${arry[0]}.log 37 38 echo "#cat $path/port"$i"_"${arry[1]}"" | tee -a 2>&1 ${arry[1]}.log 39 cat $path/port"$i"_"${arry[1]}" | tee -a 2>&1 ${arry[1]}.log 40 sleep 3 41 42 done
原文地址:https://www.cnblogs.com/maisha/p/12186031.html
时间: 2024-11-01 10:07:00