Writing a DOS Command to check text on a Website

G

Guest

Hello,
I'm trying to write a dos script (batch file) that opens a web page, and
searches for the word "Error" on a web page. if it exists, I want it to say
"error", if not, do nothing. So far, I've written the following command,
which just opens the page I want to search for the text on:

echo
echo Opening Internet Explorer
call "C:\Documents and Settings\jstevni\Desktop\CMS.mht"

Can anyone provide me the code to actually do a search? I tried ctrl + f,
but that doesn't seem to work.

Thanks!
Johnny
 
T

Tim Slattery

Johnny98 said:
Hello,
I'm trying to write a dos script (batch file) that opens a web page, and
searches for the word "Error" on a web page. if it exists, I want it to say
"error", if not, do nothing. So far, I've written the following command,
which just opens the page I want to search for the text on:

echo
echo Opening Internet Explorer
call "C:\Documents and Settings\jstevni\Desktop\CMS.mht"

Can anyone provide me the code to actually do a search?

Investigate the findstr command. You may not be able to do exactly
what you want, but it should be able to tell you whether the string
"error" is within your file.
 
G

Guest

Hello Tim -
Thank you for your response. I actually did try the FINDSTR as well as FIND
commands, but they did not work in this instance. I think those are used to
search within a physical file.
 
P

Pegasus \(MVP\)

Johnny98 said:
Hello,
I'm trying to write a dos script (batch file) that opens a web page, and
searches for the word "Error" on a web page. if it exists, I want it to say
"error", if not, do nothing. So far, I've written the following command,
which just opens the page I want to search for the text on:

echo
echo Opening Internet Explorer
call "C:\Documents and Settings\jstevni\Desktop\CMS.mht"

Can anyone provide me the code to actually do a search? I tried ctrl + f,
but that doesn't seem to work.

Thanks!
Johnny

What is "CMS.mht"?

I wrote the following batch file to get onto www.whatismyip.com
and extract my current external IP address. It consists of the
following four lines of code:

Line1 @echo off
Line2 wget www.whatismyip.com -onul
Line3 for /F "tokens=3 delims=<>- " %%a in ('type index.html ^| find /i
"WhatIsMyIP.com" ^| find /i "Title"') do echo External IP=%%a
Line4 if exist index.html del index.html

It could easily be adapted to look for the word "Error", perhaps like so:

Line1 @echo off
Line2 wget www.YourPage.com -onul
Line3 type index.html ^| find /i "Error" > nul && echo Error
Line4 if exist index.html del index.html

You can download wget.exe from http://users.ugent.be/~bpuype/wget/#download
 
N

Newbie Coder

Jonny,

Why does it have to be a batch file & not a VBS or even a 32 bit
application?

Never hard code the paths because they may need to be run on a different
machine & you would have to code
 
C

CreateWindow

Dear Johnny98,

I have a free program that will do that. There are sample scripts on my
website too.
By using JustPageProbe you will get text returned that does not contain
weird characters like 0x90 (Times new roman apostrophe) which will cause
VBScript text streams to "invalid parameter" - *crash out*. HTML streams
often contain bytes not compatible with VBScript. That's why I wrote the COM
object to do it.

You can download it from here:
http://www.easterndigitalsoftware.com/justpageprobe/justpageprobe.htm

CreateWindow
http://mymessagetaker.com
Stop using those paper phone message pads
make the computer work for you.

http://justpageprobe.com <---- Yay! here it is ;-)
The FREE Web page utility you always wanted.
Monitor your enterprise Web Servers.
Keep your router connected.
Email your IP to where you need it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top