hget: revert hget -v change, this needs more thought
problems that need to be addressed: - reads in the whole /proc every second for no reason - breaks when http server doesnt include Content-Length header - length is wrong for continued download (-o option)
This commit is contained in:
parent
ffb120199a
commit
e118352324
2 changed files with 1 additions and 38 deletions
16
rc/bin/hget
16
rc/bin/hget
|
@ -2,7 +2,7 @@
|
||||||
rfork e
|
rfork e
|
||||||
argv0=$0
|
argv0=$0
|
||||||
fn usage {
|
fn usage {
|
||||||
echo usage: $argv0 '[ -v ] [ -l | -o file] [ -p body | -P ] [ -r header ] [ -m method ] [ -b baseurl ] url' >[1=2]
|
echo usage: $argv0 '[ -l | -o file] [ -p body | -P ] [ -r header ] [ -m method ] [ -b baseurl ] url' >[1=2]
|
||||||
exit usage
|
exit usage
|
||||||
}
|
}
|
||||||
s=0
|
s=0
|
||||||
|
@ -13,7 +13,6 @@ r=()
|
||||||
m=()
|
m=()
|
||||||
b=()
|
b=()
|
||||||
l=()
|
l=()
|
||||||
v=()
|
|
||||||
while(~ $1 -*){
|
while(~ $1 -*){
|
||||||
switch($1){
|
switch($1){
|
||||||
case -o
|
case -o
|
||||||
|
@ -35,8 +34,6 @@ while(~ $1 -*){
|
||||||
case -b
|
case -b
|
||||||
b=$2
|
b=$2
|
||||||
shift
|
shift
|
||||||
case -v
|
|
||||||
v=1
|
|
||||||
case *
|
case *
|
||||||
usage
|
usage
|
||||||
}
|
}
|
||||||
|
@ -74,17 +71,6 @@ if(! ~ $s 0)
|
||||||
echo `{cat $d/parsed/url}
|
echo `{cat $d/parsed/url}
|
||||||
exit
|
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){
|
if(~ $#o 1){
|
||||||
l=`{cat $d/contentlength >[2]/dev/null}
|
l=`{cat $d/contentlength >[2]/dev/null}
|
||||||
x=`{awk 'BEGIN{FS=" |-"}/^bytes ([0-9]+)\-/{print $2}' \
|
x=`{awk 'BEGIN{FS=" |-"}/^bytes ([0-9]+)\-/{print $2}' \
|
||||||
|
|
|
@ -22,8 +22,6 @@ hget, hpost, webpaste, urlencode \- retrieve, post to a web page corresponding t
|
||||||
] [
|
] [
|
||||||
.B -b
|
.B -b
|
||||||
.I baseurl
|
.I baseurl
|
||||||
] [
|
|
||||||
.B -v
|
|
||||||
]
|
]
|
||||||
.I url
|
.I url
|
||||||
.PP
|
.PP
|
||||||
|
@ -126,15 +124,6 @@ Option
|
||||||
.B -m
|
.B -m
|
||||||
overrides the HTTP method used for the request.
|
overrides the HTTP method used for the request.
|
||||||
.PP
|
.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
|
.I Hpost
|
||||||
retrieves the web page specified by the URL
|
retrieves the web page specified by the URL
|
||||||
.I url,
|
.I url,
|
||||||
|
@ -212,18 +201,6 @@ Download a file from the web.
|
||||||
% hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg
|
% hget http://9front.org/img/nix-on.jpg >/tmp/nix-on.jpg
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Use
|
|
||||||
.I hget
|
|
||||||
in conjuncton with
|
|
||||||
.I 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
|
Retrieve the commands needed to submit a form, which may then be
|
||||||
edited and sent.
|
edited and sent.
|
||||||
.IP
|
.IP
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue