184 lines
2.8 KiB
Text
184 lines
2.8 KiB
Text
.TH HGET 1
|
|
.SH NAME
|
|
hget, hpost \- retrieve, post to a web page corresponding to a url
|
|
.SH SYNOPSIS
|
|
.B hget
|
|
[
|
|
.B -o
|
|
.I file
|
|
] [
|
|
.B -p
|
|
.I body
|
|
|
|
|
.B -P
|
|
] [
|
|
.B -r
|
|
.I header
|
|
] [
|
|
.B -m
|
|
.I method
|
|
] [
|
|
.B -b
|
|
.I baseurl
|
|
]
|
|
.I url
|
|
.PP
|
|
.B hpost
|
|
[
|
|
.B -u
|
|
]
|
|
.I url
|
|
[
|
|
.B -g
|
|
.I action
|
|
] [
|
|
.B -p
|
|
.I action
|
|
] [
|
|
.B -m
|
|
.I action
|
|
] [
|
|
.I name:value
|
|
|
|
|
.I name@file
|
|
]
|
|
.I ...
|
|
.SH DESCRIPTION
|
|
.I Hget
|
|
retrieves the web page specified by the URL
|
|
.I url
|
|
and writes it, absent the
|
|
.B -o
|
|
option, to standard output.
|
|
.PP
|
|
The
|
|
.I url
|
|
can be a relative path like
|
|
.B ../index.html
|
|
if a absolute
|
|
.I baseurl
|
|
was specified with the
|
|
.B -b
|
|
option.
|
|
.PP
|
|
If
|
|
.I url
|
|
is of type HTTP and the
|
|
.B -p
|
|
or
|
|
.B -P
|
|
options are specified, then a HTTP POST is performed.
|
|
With
|
|
.B -p
|
|
the data to be posted is provided by the
|
|
.I body
|
|
argument as a string or alternatively with
|
|
.B -P
|
|
read from standard input.
|
|
.PP
|
|
The
|
|
.B -o
|
|
option is used to keep a local file in sync with a
|
|
web page. If the web page has been modified later than the
|
|
file, it is copied into the file. If the file is up to date
|
|
but incomplete,
|
|
.I hget
|
|
will fetch the missing bytes.
|
|
.PP
|
|
Option
|
|
.B -r
|
|
sends an arbitrary HTTP
|
|
.IR header .
|
|
.PP
|
|
Option
|
|
.B -m
|
|
overrides the HTTP method used for the request.
|
|
.PP
|
|
.I Hpost
|
|
retrieves the web page specified by the URL
|
|
.I url,
|
|
parses its HTML for form data, then prints
|
|
.IR rc (1)
|
|
commands to submit the forms with default field
|
|
values.
|
|
If an
|
|
.I action
|
|
URL is provided with the
|
|
.B -g, -p
|
|
or
|
|
.B -m
|
|
flags, then
|
|
.I hget
|
|
is invoked to execute the transaction submitting the form data.
|
|
.PP
|
|
The
|
|
.B -u
|
|
flag sets the target URL to
|
|
.I url.
|
|
As the
|
|
.I url
|
|
parameter is always required, it can be optionally specified
|
|
in the first argument without the
|
|
.B -u
|
|
flag.
|
|
.PP
|
|
The
|
|
.B -g
|
|
and
|
|
.B -p
|
|
flags set the form method to GET and POST, respectively. The
|
|
.B -m
|
|
flag sets the form method to POST and its enctype to
|
|
.B multipart/form-data.
|
|
In all cases, the form action URL is set to
|
|
.I action.
|
|
.PP
|
|
The remaining arguments of the form
|
|
.B name:value
|
|
are interpreted as text form field names and values to be submitted. An
|
|
argument of the form
|
|
.B name@file
|
|
is interpreted as a file upload, with the information following the
|
|
.B @
|
|
symbol treated as the full path to the location of the file.
|
|
.SH EXAMPLES
|
|
Download a file from the web.
|
|
.IP
|
|
.EX
|
|
% hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg
|
|
.EE
|
|
.PP
|
|
Retrieve the commands needed to submit a form, which may then be
|
|
edited and sent.
|
|
.IP
|
|
.EX
|
|
% hpost http://p.intma.in
|
|
/bin/hpost -u http://p.intma.in -p paste.cgi text:
|
|
.EE
|
|
.PP
|
|
Manually specify fields to be sent to a given
|
|
.I url.
|
|
.IP
|
|
.EX
|
|
% hpost -u http://p.intma.in -p paste.cgi text:'test post'
|
|
.EE
|
|
.PP
|
|
Upload a file.
|
|
.IP
|
|
.EX
|
|
% hpost http://i.intma.in file@/tmp/screen.png | rc >/dev/null
|
|
.EE
|
|
.SH SOURCE
|
|
.B /rc/bin/hget
|
|
.br
|
|
.B /rc/bin/hpost
|
|
.SH "SEE ALSO"
|
|
.IR webfs (4) ,
|
|
.IR ftpfs (4)
|
|
.SH DIAGNOSTICS
|
|
.I Hget
|
|
requires
|
|
.IR webfs (4)
|
|
service mounted on
|
|
.B /mnt/web
|
|
to work.
|