使用Bash确定URL是HTTP还是HTTPS [英] Using Bash to determine if URL is HTTP or HTTPS
本文介绍了使用Bash确定URL是HTTP还是HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在bash中是否可以确定URL是否使用SSL?在将其他任何内容发送到URL之前,我想知道它是否仅接受HTTP或HTTPS连接.
Is there a way In bash to determine if a URL uses SSL? Before I send anything else to the URL I want to find out if it only accepts HTTP or HTTPS connections.
推荐答案
如果有权访问wget,则可以使用以下脚本.
You can use the below script if you have access to wget.
#/bin/bash
URL=google.com
if wget --spider https://$URL 2>/dev/null; then
echo "https is present"
else
echo "https not present"
fi
请注意,您需要设置http_proxy/https_proxy.
Please note that you need to have http_proxy / https_proxy set.
我在cygwin64中测试了上面的脚本[目前无法访问nix系统]
I tested the above script in cygwin64 [dont have access to nix system as of now]
您还应该能够使用curl修改相同的脚本.
You should be also able to modify the same script using curl.
这篇关于使用Bash确定URL是HTTP还是HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文