euglug.org

[Eug-lug] simple script?

작성자

카테고리:



Peter BaileySun Jun 20 19:14:04 PDT 2004

Ha!  This is good.

Unfortunately, I think they're all just a little broken.  First off, if you 
protect $@, things won't work right.  "$@" means all arguments inclusive, so 
all the arguments will be treated like one big one:

wget "http://a.com http://b.com"

This is not what you want.

wget "http://a.com" "http://b.com"

is what you want.  So, how to do that, or:

wget "http://a.com"
wget "http://b.com"

and even

wget "http://a.com/this is a link with spaces"
wget "http://b.com"

Try this one:

while [ $# -ne 0 ]; do wget r -l1 -nc --no-parent -A.pk3 "${1}"; shift; done


Keep in mind that this only takes arguments when protected by the shell:

./myscript.sh "http://www.com/this is a link" "http://a.com" 
"http://whatever.com/~!$ADSDF"

and it will fail in the case of
./myscript.sh http://www.com/this is a link

because it thinks of them all as individual arguments.


Mr O wrote:

>This what I have:
>#!/bin/sh
>wget -r -l1 -nc --no-parent -A.pk3

This is what you want.

#!/bin/sh
wget -r -l1 -nc --no-parent -A.pk3 "$@"

That will let you pull several sites in the same
command.

    ./myget.sh http://site1/foo http://site2/bar http://site3/baz

If you're tired of typing "http://", you could do this instead.

#!/bin/sh
wget -r -l1 -nc --no-parent -A.pk3 "http://$1"

    ./myget.sh site1/foo
    ./myget.sh site2/bar
    ./myget.sh site3/baz

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/