Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


VBS Expected Statement?

Posted on 2009-04-01
Medium Priority
Last Modified: 2012-05-06
I'm having an issue on line 21, 2 (Wend) with an Expected Statement

Microsoft VBScript compilation error: Expected statement

This may not have anything to do with Wend but may have something to do with incorrect statement somewhere else in the script I don't know.

Does anybody see anything obvious? What the script does is remote to a server and read the log file. If the log contains the string blahblah, it will send an email notification.

Thi sscript is very helpfull to me so if anybody can help out I would greatly appreciate it and give you 500 points :)
Const ForReading = 1
strlocalPath = "c$\corestreet\authority\logs\rtc-java-0.log"
strBadString = "No CRL available for issuer ID"
'Build the date string to look for... (ie. today's date in the format yyyy.mm.dd)
strDateLookFor = Date Part("yyyy",Date) & "." 
If Date Part("m",Date) < 10 Then strDateLookFor = strDateLookFor & "0" & Date Part("m",Date) 
	Else strDateLookFor = strDateLookFor & Date Part("m",Date)
If Date Part("d",Date) < 10 Then strDateLookFor = strDateLookFor & ".0" & 
Date Part("d",Date) _
	Else strDateLookFor = strDateLookFor & "." & Date Part("d",Date)
Set fso = CreateObject("scripting.filesystemobject")
For i = 0 To UBound(arrServers)
	Set objTxt = fso.OpenTextFile("\\" & arrServers(i) & strLocalPath,ForReading)
	While Not objTxt.AtEndOfStream
		strLine = objTxt.ReadLine
		If InStr(strLine,strDateLookFor) > 0 And InStr(strLine,strBadString) Then 
sendEmail arrServers(i),strDateLookFor,strBadString
Set fso = Nothing
Set objTxt = Nothing
Sub sendEmail(strServer,strDateLookFor,strBadString)
Set objMessage = CreateObject("CDO.Message") 
Const smtpPort = 25
Const sendUsing = 2
Const smtpServer = "yup"
objMessage.To = "yup"
objMessage.From = "yup"
objMessage.Subject = "Log Alert!"
body = "<b>A BAD entry has been found in the log file for server : " & strServer & 
body = body & "Date : " & strDateLookFor & " - " & strBadString
objMessage.HTMLBody = body
sing") = sendUsing 
erver") = smtpServer
erverport") = smtpPort 
Set objMessage = Nothing
End Sub
Open in New Window Select All

Open in new window

Question by:snyderkv
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 1000 total points
ID: 24044258
you are missing a END IF before the WEND
LVL 67

Assisted Solution

sirbounty earned 1000 total points
ID: 24044457
or you can run this command altogether since you don't have an else...

If InStr(strLine,strDateLookFor) > 0 And InStr(strLine,strBadString) Then sendEmail arrServers(i),strDateLookFor,strBadString

Author Comment

ID: 24044597
Thanks a ton that worked.

My last error may be too simple to create an all new thread over so if it's obvious to you guys please point it out. I will be waiting for the next couple hours.

Microsoft VBScript compilation error: Syntax error
The line below is the last line in the script that has issues.

Open In New Window Select All
LVL 67

Expert Comment

ID: 24044609
remove line 62 altogether...it's not script code...

Author Comment

ID: 24044662

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question