Results 1 to 3 of 3
Up until recently I used this code on Centos 5 servers as part of a more complex program to determine if a URL gives a 200 OK reply (exists) or ...
- 09-22-2011 #1Just Joined!
- Join Date
- Sep 2011
- Posts
- 1
Bash Script to Check for a "200 ok" http reply no longer working
Up until recently I used this code on Centos 5 servers as part of a more complex program to determine if a URL gives a 200 OK reply (exists) or if it doesn't...
usage: sh scriptname website
(where someurl would be a proper url)Code:#!/bin/sh $website=someurl lynx -dump "$website" &> /dev/null if [[ $? -eq 0 ]]; then echo Web Page Exists else echo Web Page Doesnt exist fi
Trying this on modern Debian 6.0 and latest Ubuntu doesn't work. It produces an output that isn't silent at all... it tries to open alternative web pages and it doesn't give a reliable response.
What options can I use with lynx to make it work like the old lynx? and if not...
What other methods can I use in bash to check if a URL gives a 200OK response or not?
Any Help or Ideas are greatly appreciated...Last edited by expatsys; 09-22-2011 at 05:00 AM. Reason: Courtesy
- 09-22-2011 #2
If lynx won't behave, try wget.
GNU Wget 1.13.4 Manual
- 09-22-2011 #3Linux Guru
- Join Date
- May 2011
- Posts
- 1,843
I agree, wget is great for this. This is what I typically use:
Here's some others (not as reliable but also useful):Code:wget --timeout=1 --tries=1 --output-document=- --server-response localhost:80
Code:http_ping http://locahost:80 httpping http://localhost:80 nmap -n localhost -p 80


Reply With Quote