Advertisement

08.24.2008 at 06:38PM PDT, ID: 23674310
[x]
Attachment Details

Windows MSDOS scripting (.cmd & .bat) questions (Errorlevel  & equivalent of Unix sleep)

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.9
Tags:

Microsoft, Windows MSDOS scripting (.cmd & .bat), XP professional, Windows MSDOS scripting (.cmd & .bat) questions

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 --------------------------------------
Answered By: doraemon2555
Expert Since: 07/20/2008
Accepted Solutions: 8
doraemon2555 has been an Expert for 5 months, during which he has posted 33 comments and answered 8 questions. doraemon2555 is just one of 1209 experts in the Windows Batch Scripting Zone. 2 experts collaborated on this answer, which was graded a "B" by the asker.
 
 
20081119-EE-VQP-48 / EE_QW_2_20070628