What webserver shell function

This is lifted from http://bashcurescancer.com/shell-function-which-webserver-does-that-site-run.html.

Handy shell function you can put in your .bashrc. Quickly find out what server a host is running.

what-http-server() { curl -s -I $(for h in "$@"; do printf "http://%s " "$h"; done) | awk -F': ' '/^Server:/ {print $2}'; }

Now try what-http-server kernel.org google.com hotmail.com.

One Comment

  • Here’s a diet version for a single host:
    $ curl -sI google.com | grep Server

    Here’s a version with only alphabet letters and dashes & pipes:
    $ lessecho google.com wpi.edu | xargs curl -sI | grep Server
    (lessecho comes with less, xargs with findutils, at least in Debian/Ubuntu)

    what-http-server() { lessecho $@ | xargs curl -sI | grep Server }

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha