Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / functions / gethtml
blob2eec1d89fe9d3ab4c546f9e4a85fb357b1aa5054
2 # get_html -- get a web page from a remote server
4 # Original Author: Jeff Korn <jlk@cs.princeton.edu>
5 # Modified for bash by Chet Ramey <chet@po.cwru.edu>
7 # Example: get_html cnswww.cns.cwru.edu /~chet/ | more
9 get_html()
11         local host port
13         (($# < 2)) && {
14                 echo "usage: $FUNCNAME hostname path [port]" >&2
15                 return 1
16         }
18         host="$1"
19         port="${3:-80}"
21         exec 3<> /dev/tcp/$host/$port || {
22                 echo "$FUNCNAME: $host/$port: cannot connect" >&2
23                 exit 1
24         }
26         echo -e "GET $2 HTTP/1.0\n" >&3
28         cat <&3
30         exec 3<&-
32         return 0
35 get_html "$@"