Check wget’s return value

Others have correctly posted that you can use $? to get the most recent exit code:

wget_output=$(wget -q "$URL")
if [ $? -ne 0 ]; then
    ...

This lets you capture both the stdout and the exit code. If you don’t actually care what it prints, you can just test it directly:

if wget -q "$URL"; then
    ...

And if you want to suppress the output:

if wget -q "$URL" > /dev/null; then
    ...

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)