-1

I'm trying to execute the following shell script, where I'm trying to keep executing a command in an infinite loop and until the output is not equal to a certain substring

checkDeviceStatus=$(adb shell getprop sys.boot_completed 2>&1)

function Check_Status () {

while [ ! "$checkDeviceStatus" =~ "device offline" ] || [ ! "$checkDeviceStatus" =~ "device still authorizing" ]
  do
  if [ ! "$checkDeviceStatus" =~ "device offline" ] || [ ! "$checkDeviceStatus" =~ "device still authorizing" ];
       then
          echo "Device is now up and running!!: '$checkDeviceStatus'"
          break
       else 
            echo "'$checkDeviceStatus'"
       fi;
done

};

Check_Status

but I'm getting the following error

./shell.sh: line 6: [: =~: binary operator expected
./shell.sh: line 8: [: =~: binary operator expected
3
0
#!/bin/bash

function Check_Status () {

while [[ "$(adb shell getprop sys.boot_completed 2>&1)" =~ "device offline" ]] || [[ "$(adb shell getprop sys.boot_completed 2>&1)" =~ "device still authorizing" ]] || [[  "$(adb shell getprop sys.boot_completed 2>&1)" =~ "no devices/emulators found" ]];
  do
  sleep 1
  if [[ "$(adb shell getprop sys.boot_completed 2>&1)" == "" ]] || [[ "$(adb shell getprop sys.boot_completed 2>&1)" == 1 ]];
  then 
     echo "Device is now up and running!!: '$(adb shell getprop sys.boot_completed 2>&1)'"
     break      
  else 
     echo "'$(adb shell getprop sys.boot_completed 2>&1)':("
  fi    
done

};

Check_Status

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.