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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-22-2011 #1
- Join Date
- Sep 2011
Bash Script to Check for a "200 ok" http reply no longer working
usage: sh scriptname website
#!/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
- 09-22-2011 #3
- Join Date
- May 2011
I agree, wget is great for this. This is what I typically use:
wget --timeout=1 --tries=1 --output-document=- --server-response localhost:80
http_ping http://locahost:80 httpping http://localhost:80 nmap -n localhost -p 80