Hi,
Need some help with writing a short MSDOS Windows script to monitor
a website's status & email the status out. The script will be run once a
day by Windows scheduler (script will loop 48 times x 15 minutes in a
day). In case a Website/link is down, the script will send a notification
email & then exit/stop (& not keep sending notification email every 15
minutes).
I'm using a utility called wget-1.10.exe to check a website's status.
I know how to handle the emailing part as I have a tool to do that, so
you may assume I have no problem with emailing part.
Refer to the draft codes below, I have 3 questions :
a)is my coding for iterating/looping 48 times correct or give
me the correct coding for the .cmd or .bat if my codes below
are incorrect
b) "if not Errorlevel 0 echo website is down > status.txt" -
when I tested the above codes by echoing to screen (instead
of to an output file), regardless of whether the website is up
or down, it always echo nothing out regardless of the value
of Errorlevel (ie whether the text "connected" is found or not).
What am I missing here?
How do I enclose the "if" loop which has 3 actions (need actual codes) :
echo ... > status.txt
send email out (this part I know)
exit (ie stop further execution of script)
c) in Unix shell scripting, we have "sleep x" to pause the script for x seconds
- how do we achieve this in MSDOS/Windows scripting?
Thanks
+++++++++++++++++++ Checkwebpage.bat :+++++++++++++++++++++
n=0
Loop:
n=n+1
if n > 48 then exit this script <== a) iterate 48 times
wget-1.10 --tries=1 --proxy tanglinvillage.com > a.txt 2> a.err
find "connected" a.err
if not Errorlevel 0 echo website is down > status.txt
(& email out status.txt & exit this script) <== b)
sleep 15minutes <== c) how to achieve this?
goto Loop
--------------------------
----------
End of script --------------------------
----------
--
Start Free Trial