Computing.Net > Forums > Unix > Script to find whether link is up

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Script to find whether link is up

Reply to Message Icon

Name: Net
Date: October 6, 2008 at 08:39:16 Pacific
OS: SUN
CPU/Ram: 256
Product: .
Comment:

I need to check the availability of a web page for every one hour through a script. Following is the requirement.

1. Go to http://someone.com
2. If any error encountered in opening the home page, it should trigger an email with the appropriate error message.

Need help on this ....



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: October 7, 2008 at 21:46:47 Pacific
Reply:

You might try using the lynx browser command. lynx is used by character devices so it works well in a script:

#!/bin/bash

# website to check
web="http://www.computing.nnet"

# The exit code of the lynx command equals zero if it can open the webpage else it is non-zero if it can not:


lynx -dump "$web" &> /dev/null
if [[ $? -eq 0 ]]
then
echo "$web web page exists"
else
echo "$web web page does NOT exist. Execute the email command"
fi


lynx is typically bundled with Linux, but isn't always installed on other distributions. If you don't have it, this is the homepage:

http://lynx.isc.org/

lynx has a ton of other options that you might find useful.



0

Response Number 2
Name: Net
Date: October 8, 2008 at 03:20:15 Pacific
Reply:

Thanks for your response

the script should work in UNIX box.
but the code provided above has the linux command.

Can you please provide me a script that works with UNIX command.

Thanks in advance


0

Response Number 3
Name: nails
Date: October 8, 2008 at 06:31:24 Pacific
Reply:

If you are not willing to download the lynx package, then I can not do anything for you.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Script to find whether link is up

Script to find if file is to old www.computing.net/answers/unix/script-to-find-if-file-is-to-old/5740.html

finding whether a file is empty www.computing.net/answers/unix/finding-whether-a-file-is-empty/7048.html

A simple script for creating a link www.computing.net/answers/unix/a-simple-script-for-creating-a-link/6981.html