Forum Moderators: bakedjake

Message Too Old, No Replies

wget from shell script

a confused beginner...

         

jamie

10:21 am on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi,

i have a simple script which runs wget to mirror a complete website

#!/bin/sh
wget -N options savepath url

this works fine.

i'd like to refine it to read a list of URLs from a file:

while read f
do
echo "url = $f"
`wget -N -P$SAVE_PATH $LOGIN $f`
done < $file

the script reads the file correctly and echoes out a list of URLs, but if i enclose wget in backquotes i get GNU: command not found. but if i leave the quotes off, then i get the standard blurb about wget echoed to my screen.

obv. no file is mirrored ;-)

how do i invoke wget in this instance?

many thanks!

<added> found it - it was all in the syntax. it needs backquotes and correct order of wget syntax:
`wget -N $LOGIN -P $SAVE_PATH $f`

thanks anyway :-)

tschild

2:56 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



I see you got a solution to the problem using your looping script.

Another solution would be to dispense with the loop and use the -i option of wget to specify a file listing the URLs to be retrieved.

jamie

3:12 pm on Jan 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi tschild,

yeah i just found that out myself too ;-)

although the only way i could get the URLs from a file into the one var was:

while read f
do
var="$var $f"
done < $f

`wget -N $LOGIN -P $SAVE_PATH -I $var`

it works by concatting each line $f to the $var, separated by a space. i come from php so was searching in vain for $var .= $f but couldn't find it. is there such a thing in a shell script?

cheers