source: vendor/bash/3.1-p17/examples/functions/gethtml

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

File size: 558 bytes
Line 
1#
2# get_html -- get a web page from a remote server
3#
4# Original Author: Jeff Korn <jlk@cs.princeton.edu>
5# Modified for bash by Chet Ramey <chet@po.cwru.edu>
6#
7# Example: get_html cnswww.cns.cwru.edu /~chet/ | more
8
9get_html()
10{
11 local host port
12
13 (($# < 2)) && {
14 echo "usage: $FUNCNAME hostname path [port]" >&2
15 return 1
16 }
17
18 host="$1"
19 port="${3:-80}"
20
21 exec 3<> /dev/tcp/$host/$port || {
22 echo "$FUNCNAME: $host/$port: cannot connect" >&2
23 exit 1
24 }
25
26 echo -e "GET $2 HTTP/1.0\n" >&3
27
28 cat <&3
29
30 exec 3<&-
31
32 return 0
33}
34
35get_html "$@"
Note: See TracBrowser for help on using the repository browser.