October 29, 20178 yr I used to have a script that would check if the array was started and parity check was not running before backing up files. Using: #!/bin/bash var=/proc/mdcmd array=$(grep -Po '^mdState=\K\S+' $var) rsync=$(grep -Po '^mdResync=\K\S+' $var) if [[ $array == STARTED && $rsync -eq 0 ]]; then rysnc script fi I saw that from rc8 onwards the preferred method to read array status is by quering the var.ini and disks.ini files. so I updated the a test script to the following: #!/bin/bash var=/var/local/emhttp/var.ini array=$(grep -Po '^mdState=\K\S+' $var) rsync=$(grep -Po '^mdResync=\K\S+' $var) echo $array echo $rsync if [[ $array == STARTED ]]; then echo "ARRAY STARTED" else echo "ARRARY NOT STARTED" fi if [[ $rsync -eq 0 ]]; then echo "RSYNC 0" else echo "RSYNC Running" fi and my output is: "STARTED" "0" ARRARY NOT STARTED ./test: line 17: [[: "0": syntax error: operand expected (error token is ""0"") RSYNC Running Does anyone know why the if else logic is coming back false instead of true like the echo variables are stating? Edited October 29, 20178 yr by archedraft
October 29, 20178 yr Your result includes quotes. Do this: array=$(grep -Po '^mdState="\K[^"]+' $var)
October 29, 20178 yr Author 1 hour ago, bonienl said: Your result includes quotes. Do this: array=$(grep -Po '^mdState="\K[^"]+' $var) Thank you! @bonienl
Archived
This topic is now archived and is closed to further replies.