summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormischief <mischief@offblast.org>2014-03-22 23:28:42 -0700
committermischief <mischief@offblast.org>2014-03-22 23:28:42 -0700
commita710914b36db4d52ce557dab98b3208c9af95667 (patch)
treecc38f1929e00d768540a51da250596bab83947ba
parent0d080855b2a1b8095f2a7d4c6f649685d20e3c42 (diff)
downloadplan9front-a710914b36db4d52ce557dab98b3208c9af95667.tar.xz
hget: add the -v option to produce progress on stderr, like old hget
-rwxr-xr-xrc/bin/hget16
-rw-r--r--sys/man/1/hget21
2 files changed, 36 insertions, 1 deletions
diff --git a/rc/bin/hget b/rc/bin/hget
index 82b9cba67..fb7534403 100755
--- a/rc/bin/hget
+++ b/rc/bin/hget
@@ -2,7 +2,7 @@
rfork e
argv0=$0
fn usage {
- echo usage: $argv0 '[ -l | -o file] [ -p body | -P ] [ -r header ] [ -m method ] [ -b baseurl ] url' >[1=2]
+ echo usage: $argv0 '[ -v ] [ -l | -o file] [ -p body | -P ] [ -r header ] [ -m method ] [ -b baseurl ] url' >[1=2]
exit usage
}
s=0
@@ -13,6 +13,7 @@ r=()
m=()
b=()
l=()
+v=()
while(~ $1 -*){
switch($1){
case -o
@@ -34,6 +35,8 @@ while(~ $1 -*){
case -b
b=$2
shift
+ case -v
+ v=1
case *
usage
}
@@ -71,6 +74,17 @@ if(! ~ $s 0)
echo `{cat $d/parsed/url}
exit
}
+ if(~ $#v 1){
+ hpid=$pid
+ @{
+ while(ls /proc | grep -s $hpid) {
+ have=`{grep '^ 0' /proc/$hpid/fd | awk '{ print $9 }' }
+ want=`{cat $d/contentlength}
+ echo $have $want >[1=2]
+ sleep 1
+ }
+ } &
+ }
if(~ $#o 1){
l=`{cat $d/contentlength >[2]/dev/null}
x=`{awk 'BEGIN{FS=" |-"}/^bytes ([0-9]+)\-/{print $2}' \
diff --git a/sys/man/1/hget b/sys/man/1/hget
index a8671369d..6857015bb 100644
--- a/sys/man/1/hget
+++ b/sys/man/1/hget
@@ -22,6 +22,8 @@ hget, hpost, webpaste, urlencode \- retrieve, post to a web page corresponding t
] [
.B -b
.I baseurl
+] [
+.B -v
]
.I url
.PP
@@ -124,6 +126,15 @@ Option
.B -m
overrides the HTTP method used for the request.
.PP
+Option
+.B -v
+causes
+.I hget
+to emit download status on file descriptor 2,
+suitable for use with
+.I aux/statusbar .
+See EXAMPLES.
+.PP
.I Hpost
retrieves the web page specified by the URL
.I url,
@@ -201,6 +212,16 @@ Download a file from the web.
% hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg
.EE
.PP
+Use
+.I hget
+in conjuncton with aux/statusbar to monitor progress.
+.IP
+.EX
+hget -v -o 9front.iso.bz2 \\
+ http://www.r-36.net/9front/9front.iso.bz2 \\
+ |[2] aux/statusbar '9front.iso.bz2'
+.EE
+.PP
Retrieve the commands needed to submit a form, which may then be
edited and sent.
.IP