I have a case where a first few command execution attempts after daemon restart are returning 2 (followed by stderr messages), than everything works correctly.
In order to bypass this bug I've come to an idea that I should utilize while/do/done/until
functionality with some sleep
, but the fun part is that I should have all the data I'd get by the regular execution way:
...
RESULT=$(command param1 param2 2>&1)
SIG=$?
...
So is there a way to execute command param1 param2
repeatedly until exit status is NOT 2 (any given value) and to have STDOUT+STDERR in a variable RESULT
and exit status in variable SIG
, as presented?