Web Hosting Talk







View Full Version : wget if linux question


edb49
08-20-2002, 10:09 AM
Linux is driving me spare, I want a bit of code that does the following:

wget http://server/file.zip
if [wget succeeds]; then
echo Doing things
fi

I've tried:
if [ "$?" -eq 0 ]; then
but no luck...

ffeingol
08-20-2002, 10:20 AM
Well it really depends on what shell the script is coded in, but I believe you want:


if [ $? -eq 0 ]; then


$? is the return code from the last executed program. You don't need/want quotes around it.

Frank

edb49
08-20-2002, 10:38 AM
Thanks Frank, I'll give it a go

It's using /bin/sh - annoyingly simple answer!
:angry:

:)