[read -p应用]插拔光模块去检查port present状态
Posted maisha
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[read -p应用]插拔光模块去检查port present状态相关的知识,希望对你有一定的参考价值。
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 33[31m ["$i"] 33[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. 33[31m ["$i"] 33[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
以上是关于[read -p应用]插拔光模块去检查port present状态的主要内容,如果未能解决你的问题,请参考以下文章
leetcode 157. Read N Characters Given Read4 利用read4实现read --------- java