在我的脚本上设置超时和错误消息

发布于 2025-02-10 21:16:42 字数 344 浏览 1 评论 0原文

我有一个脚本,我试图为如果OPENSL的长时间创建错误消息和超时。这是脚本。谁能帮我吗?我有点迷路。


FILENAME=$1
while read -r ip; do
 echo "${ip}"
 echo -n | openssl s_client -connect "${ip}:443" -showcerts 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -noout -dates

done < <(cut -d "," -f2 $FILENAME | tail -n +2)

I have a script that im trying to create an error message and timeout for if the openssl takes to long. Here is the script. Can anyone help me? I'm a little lost.


FILENAME=$1
while read -r ip; do
 echo "${ip}"
 echo -n | openssl s_client -connect "${ip}:443" -showcerts 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | openssl x509 -noout -dates

done < <(cut -d "," -f2 $FILENAME | tail -n +2)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

机场等船 2025-02-17 21:16:42

您可以从gnu core utils软件包中使用超时手动
也许做类似的事情:

while read -r ip; do
 timeout [timeout duration] [your ssl command]

 if [ $? -eq 124 ]; then
  echo FAIL
 else
  echo OK
 fi
done

You could use timeout from gnu core utils package(manual)
Maybe do something like:

while read -r ip; do
 timeout [timeout duration] [your ssl command]

 if [ $? -eq 124 ]; then
  echo FAIL
 else
  echo OK
 fi
done
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文