Bash Shell Do While Loop Infinite loop? Bash Shell Do While Loop Infinite loop? bash bash

Bash Shell Do While Loop Infinite loop?


You are not updating your bay variable inside of the loop somewhere. It gets set once and stays the same. You need to recalculate it every time.

Either set bay within the loop, or in the condition of the while.

while [ `prog -some flags` = "Another instance of this program is running, please exit it first" ]

Edit:

From your comment, you want to be able to reference this output later. You can go back to what you had, but inside of your blocking loop, put your bay=$(prog -some flags) command inside of the loop. It will stick around for you to use later.

bay=$(prog -some flags)while [ $bay = "Another instance of this program is running, please exit it first" ]doecho "Awaiting Access to program"bay=$(prog -some flags)done.....


More DRY and instead of hammering prog, I'd wait for the user to do something first:

while truedo  bay=$(prog -some flags)  case "$bay" in    "Another instance of this program is running, please exit it first")      read -p "Awaiting Access to program. Close it and hit enter: " x ;;    *) break ;;  esacdoneecho "Results: $bay"