0
我用簡單的代碼來測試一些服務:Netcat - 如何獲得連接時間?
nc -v -w 2 google.com 80
Connection to google.com 80 port [tcp/http] succeeded!
它工作得很好,但我也需要有一個連接時間。是否有可能通過netcat獲取它?我不能手動:(
我用簡單的代碼來測試一些服務:Netcat - 如何獲得連接時間?
nc -v -w 2 google.com 80
Connection to google.com 80 port [tcp/http] succeeded!
它工作得很好,但我也需要有一個連接時間。是否有可能通過netcat獲取它?我不能手動:(
在發現這是這一點,你想要什麼
echo "[$(date)] Connection to $SERVER $PORT port [tcp/http] $(nc -z $SERVER $PORT &> /dev/null && echo succeeded || echo failed)"
?例如:
$ echo "[$(date)] Connection to google.com 80 port [tcp/http] $(nc -z google.com 80 &> /dev/null && echo succeeded || echo failed)"
[Mon Apr 10 12:40:31 UTC 2017] Connection to google.com 80 port [tcp/http] succeeded
$ echo "[$(date)] Connection to google.com 80 port [tcp/http] $(nc -z google2.com 80 &> /dev/null && echo succeeded || echo failed)"
[Mon Apr 10 12:40:20 UTC 2017] Connection to google.com 80 port [tcp/http] failed