How to create a loop in bash that is waiting for a webserver to respond?

前端 未结 6 1121
半阙折子戏
半阙折子戏 2020-12-12 16:48

How to create a loop in bash that is waiting for a webserver to respond?

It should print a \".\" every 10 seconds or so, and wait until the server starts to respond.

6条回答
  •  佛祖请我去吃肉
    2020-12-12 17:20

    Interesting puzzle. If you have no access or async api with your client, you can try grepping your tcp sockets like this:

    until grep '***IPV4 ADDRESS OF SERVER IN REVERSE HEX***' /proc/net/tcp
    do
      printf '.'
      sleep 1
    done
    

    But that's a busy wait with 1 sec intervals. You probably want more resolution than that. Also this is global. If another connection is made to that server, your results are invalid.

提交回复
热议问题