Guest User

Untitled

a guest
May 28th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. wait_for_hosts () {
  4. for host in $@; do
  5. while ! timeout 5 bash -c "echo > /dev/tcp/${host//:/\/}"; do
  6. echo "$host is not available. Retrying..."
  7. sleep 2
  8. done
  9. echo $host is available!
  10. done
  11. }
  12.  
  13. WAIT_FOR_HOSTS="google.com:80 google.de:80 bing.com:443"
  14. wait_for_hosts $WAIT_FOR_HOSTS
  15.  
  16. wait_for_hosts google.com:80 google.de:80 bing.com:443
Add Comment
Please, Sign In to add comment