Created
October 23, 2023 00:35
-
-
Save jimdiroffii/e06bcc5dc9fcfffb02e5da2538ed35f5 to your computer and use it in GitHub Desktop.
Run a program until some output string is found
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
counter=0 | |
while true; do | |
counter=$((counter + 1)) | |
output=$(./MyApp) # Execute the program and store its output | |
last_line=$(echo "$output" | tail -n 1) # Extract the last line of the output | |
echo "$output" # Print the output | |
if [ "$last_line" == "output" ]; then # Change this string to desired match | |
echo "Output found after: $counter" # Shows number of program executions | |
break # Exit the loop if the last line is "output" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment