john john - 2 months ago 5
Bash Question

Using Bash to determine if URL is HTTP or 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.


You can use the below script if you have access to wget.

if wget --spider https://$URL 2>/dev/null; then
  echo "https is present"
  echo "https not present"

Please note that you need to have http_proxy / https_proxy set.

I tested the above script in cygwin64 [dont have access to nix system as of now]

You should be also able to modify the same script using curl.