Im a little confused, I have a function that returns a exit code value and is also returning output, from running two expect scripts (I produce an exit code from the first script, and output from the second, in the function).
I am trying to figure out how use this function in a loop. I would like to loop the function until the exit code is zero, and then store the output value in a variable. Im a little stumped how to do this, I wonder if anyone can advise? My goal is:
run_expect_scripts()
{
expect expect_script1
exit_value="$?"
output=$(expect expect_script2)
echo "$output"
return "$exit_value"
}
until [ run_expect_scripts -eq 0 -o a_counter -eq 5 ]; do
a_counter=$(expr a_counter + 1)
sleep 2s
done
use output of run_expect_scripts
Please how can I do this better?