Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Script error 1

Status
Not open for further replies.

DrSeussFreak

Programmer
Feb 16, 2007
149
US
Ok, so any ideas on how to make this work?

Code:
const ForReading = 1
dim strSearchThis
dim objFS
dim objTS
set objFS = Server.CreateObject("Scripting.FileSystemObject")
set objTS = objFS.OpenTextFile(Server.MapPath("D:\oracle\dba_util\scripts\log\tspace.log"), _
                               ForReading)

strSearchThis = objTS.ReadAll
if instr(strSearchThis, "-") > 0 Then
	SendEmail "to", "from", "MARS - Daily Extent Report", objTS
Else
	SendEmail "to", "from", "MARS - Daily Extent Report", "All is ok"
End If

Sub SendEmail(strTo, strFrom, strSubject, strMsg)
    schema = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/"[/URL]
    SmtpServer = "SMTP Here"

    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = strFrom
    objEmail.To = strTo
    objEmail.Subject = strSubject
    objEmail.Textbody = strMsg
    objEmail.Textbody = objEmail.Textbody & VbCrLf

    objEmail.Configuration.Fields.Item (schema & "sendusing") = 2
    objEmail.Configuration.Fields.Item (schema & "smtpserver") = SmtpServer
    objEmail.Configuration.Fields.Item (schema & "smtpserverport") = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send
End Sub

Error is

D:\oracle\dba_util\scripts\TSpaceChecker.vbs(5, 1) Microsoft VBScript runtime error: Object required: 'Server'
 
Ok, so I changed it to

Code:
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("D:\oracle\dba_util\scripts\log\tspace.log", _
    ForReading)

strSearchThis = objTextFile.ReadAll
if instr(strSearchThis, "-") > 0 Then
	SendEmail "to", "from", "MARS - Daily Extent Report - Not Ok", objTextFile.ReadAll
Else
	SendEmail "to", "from", "MARS - Daily Extent Report - OK!", _
							"Ohh, what a wonderful world"
End If

Sub SendEmail(strTo, strFrom, strSubject, strMsg)
    schema = "[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/"[/URL]
    SmtpServer = "SMTP Server"

    Set objEmail = CreateObject("CDO.Message")
    objEmail.From = strFrom
    objEmail.To = strTo
    objEmail.Subject = strSubject
    objEmail.Textbody = strMsg
    objEmail.Textbody = objEmail.Textbody & VbCrLf

    objEmail.Configuration.Fields.Item (schema & "sendusing") = 2
    objEmail.Configuration.Fields.Item (schema & "smtpserver") = SmtpServer
    objEmail.Configuration.Fields.Item (schema & "smtpserverport") = 25
    objEmail.Configuration.Fields.Update
    objEmail.Send
End Sub
 
it works for when there is no '-' in the file, but when there is a '-' in the log file, I get

D:\oracle\dba_util\scripts>tspacechecker2.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

D:\oracle\dba_util\scripts\TSpaceChecker2.vbs(9, 2) Microsoft VBScript runtime
error: Input past end of file
 
Try this:
Code:
if instr(strSearchThis, "-") > 0 Then
    SendEmail "to", "from", "MARS - Daily Extent Report - Not Ok", [COLOR=blue]strSearchThis [/color][s]objTextFile.ReadAll[/s]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top