LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash scripting to check text in a website (https://www.linuxquestions.org/questions/programming-9/bash-scripting-to-check-text-in-a-website-365206/)

carlp 09-20-2005 08:54 AM

Bash scripting to check text in a website
 
Hi,

I'm building a bash script that will be checking a website for any errors.
I've been looking around and a found a script to check the BBC website for stories from the technology site. Looking at the code, its very small, but it uses SED and im like ARGH! so I have no idea.

Can anyone help me build this, what I hope simple script? The script is to check a site, and if sees 'Site Navigation' it prints to a log 'Time - Site OK' or if it finds 'Error' it prints to a log 'Time - Error - Person notified' which then, as you can tell from the log, it emails using the mail command..

Any help, would be most appreciated..

Regards,

Carl

pycoucou 09-20-2005 10:59 AM

Not very clear question...

What do you really want to check? Your logs or the source files of your website?

sed and awk are really powerful tools to check string in a text file. grep is much simpler if you know the exact string you're looking for. I'm not a sed/awk guru but have a look around about regular expression. That's what sed is going to detect... For instance, any sentence starting with 'qwer' or whatever.

carlp 09-20-2005 11:14 AM

Hi,

I'm going to be checking the website itself. I'll explain in more depth and the process

The script runs and opens a connection to a specified URL using lynx

The page is then checked for some text.
If the text is 'Step 2' then the following is entered into the log 'Site checked at TIME - OK'
If the text is 'error' then the following is entered into the log 'Site checked at TIME - person informed'


So what is happening is its an early warning script if any errors appears it lets us know. I've been playing and well, all I've got is

Code:

url="http://www.domain.com/site.html"

lynx -dump $url | \
  grep 'Step 2'



All times are GMT -5. The time now is 02:13 AM.