LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-20-2005, 08:54 AM   #1
carlp
LQ Newbie
 
Registered: Jun 2005
Location: England
Distribution: Debian, Slackware, EnGarde, Ubuntu!
Posts: 7

Rep: Reputation: 0
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
 
Old 09-20-2005, 10:59 AM   #2
pycoucou
Member
 
Registered: Apr 2004
Location: Edinburgh
Posts: 78

Rep: Reputation: 15
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.
 
Old 09-20-2005, 11:14 AM   #3
carlp
LQ Newbie
 
Registered: Jun 2005
Location: England
Distribution: Debian, Slackware, EnGarde, Ubuntu!
Posts: 7

Original Poster
Rep: Reputation: 0
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'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH scripting: check for numeric values linuxLuser Programming 11 11-14-2011 10:11 AM
How you check a website within a network helios007 Linux - Newbie 3 11-13-2003 07:39 PM
Program to check if website is working jpc82 Linux - Software 0 10-16-2003 07:54 AM
New band, New website, check it out:) Shade General 4 09-10-2003 11:25 PM
Help check speed of a website! DavidPhillips General 6 01-02-2003 07:50 PM


All times are GMT -5. The time now is 01:27 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration