Allright...
I have a event that generates a textfile with 1 line of information.
I have HostMonitor checking if the file exists.
If it does, I want HostMonitor to send an SMS containing the contents of the first (and only) line of text in the textfile, and then delete the textfile.
I know how to check for the textfile's existence, how to send an SMS when it does, and delete the textfile once the SMS is sent.
But how do I get the contents of the textfile in the SMS message???
Thanks!
EDIT:
I found a post on this forum from 3 years back.
Apparently this can't be done.
Maybe one for the wish-list?
SMS content of textfile
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
You may use Shell Script test method to perform any custom test.
E.g. You may write your own script that will check if file exists. If file exists test will get "Bad" status and set first line of text file as test Reply.
Then you may setup SMS alert with %Reply% macro-variable.
ShellScript may look like the following:
Start cmd: cmd /c cscript /B /E:VBScript %Script% %Params%
Please check the manual or visit our web site for more information at:
%Reply% macro-variable: http://www.ks-soft.net/hostmon.eng/mfra ... #currmacro
Shell Script test method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
E.g. You may write your own script that will check if file exists. If file exists test will get "Bad" status and set first line of text file as test Reply.
Then you may setup SMS alert with %Reply% macro-variable.
ShellScript may look like the following:
Code: Select all
' Script check if file exists
' If file doesn't exists "Ok" status is returned
' If file exists, Reply contains 1st line of text file.
Option Explicit
const statusOk = "scriptRes:Ok:"
const statusBad = "scriptRes:Bad:"
const statusUnknown = "scriptRes:Unknown:"
dim objArgs, objFSO, objTextFile, FileName, firstline
Set objArgs = WScript.Arguments
if objArgs.count < 1 then
WScript.StdOut.Write statusUnknown & "expected params: <path to file>"
WScript.Quit
end if
FileName = objArgs(0)
Set objFSO = Wscript.CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(FileName) Then
Set objTextFile = objFSO.OpenTextFile(FileName, 1)
firstline = objTextFile.ReadLine
objTextFile.Close
WScript.StdOut.Write statusBad & firstline
Else
WScript.StdOut.Write statusOk & "File does not exist."
End If
Please check the manual or visit our web site for more information at:
%Reply% macro-variable: http://www.ks-soft.net/hostmon.eng/mfra ... #currmacro
Shell Script test method: http://www.ks-soft.net/hostmon.eng/mfra ... m#chkShell
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact: