Amir Rachman Amir Rachman - 1 month ago 24
Bash Question

grep on lynx command

I want to grep the result on lynx command

lynx -head -dump http://abdsadsac.org


Result for that command

Looking up 111.111.111.111:9004
Making HTTP connection to 111.111.111.111:9004
Alert!: Unable to connect to remote host.

lynx: Can't access startfile http://abdsadsac.org


I want that word replace to be 0 or down, I try to create bash script, but that command still shown. Result that i want is.

#lynx -head -dump http://abdsadsac.org
Down


Already try to use if else on the bash but still doesn't work.

Answer

How about using the exit code to determine if the site is up?

For example:

$ lynx -head -dump http://abdsadsac.org 2> /dev/null || echo Down
Down