Click to See Complete Forum and Search --> : wget's console output > variable


kotj.mf
01-13-2005, 03:50 PM
I need to output wget's stdout to a string in a shell script, eg:

mystring=`wget -nv --spider http://whatever`

...and do stuff based on what http status code I get.

Problem is, it keeps outputting to the console, and my string is empty.

Poking around, I've noticed that I can't even redirect it to a file.

wget -nv --spider http://whatever > file

gives stdout and an empty file.

I suppose I could output everything to a wget log file, but a) I'm planning on passing some variables to wget that I'd need to log, too, and b) it's ugly.

What am I missing here?

Thanks.

lagitus
01-13-2005, 04:05 PM
wget seems to print its output to stderr by default. Try this:

VAR=`wget something 2>&1`

kotj.mf
01-13-2005, 04:10 PM
That did it. Muchas gracias.