Capture http response code from wget

Hi All,

I am using wget to call a url..i am getting 202 if it is successful. if not i am forcing the response code to 417.

how can i capture the response code and print 0 if it is 202 and 1 if it is not 202

any ideas, please share

Thanks,
Jack.

(($?==202)) will return 0 if $? is 202

You'll want the --server-response option, eg

wget --server-response http://localhost/nx.file 2>&1 | awk '/^  HTTP/{print $2}'