Skip to content

Instantly share code, notes, and snippets.

@andgineer
Last active October 21, 2019 10:03
Show Gist options
  • Save andgineer/2555ba583bc675bf63e0fa399c627851 to your computer and use it in GitHub Desktop.
Save andgineer/2555ba583bc675bf63e0fa399c627851 to your computer and use it in GitHub Desktop.
wait for specific string from application with timeout
timeout -k 1s --preserve-status 0.5s \
perl -e '$|++; print "bla-bla\n"; sleep(2); print "The end."' \ # placeholder for you process
| perl -pe 'END { exit $status } $status=1; if (/end/) {$status=0; exit;}'
# see explanation in andrey.engineer/posts/en/bash_wait_with_timeout_for_string.html
@andgineer
Copy link
Author

Description is in my blog post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment