View previous topic :: View next topic |
Author |
Message |
Revro
Joined: 27 Apr 2016 Posts: 17
|
Posted: Wed May 04, 2016 8:45 am Post subject: Read text file and display text |
|
|
Hello, it's me again ...
I would like to know if it is possible to display the content of a text file without use HMS Script in the Supervision Screen.
Thanks again. |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Wed May 04, 2016 9:07 am Post subject: |
|
|
You may use Shell Script test with simple JS script:
Code: | statusUnknown = "ScriptRes:Unknown:";
statusOk = "ScriptRes:Ok:";
statusBad = "ScriptRes:Bad:";
var objArgs = WScript.Arguments;
if (objArgs.length!=1) {
WScript.StdOut.Write(statusUnknown + 'Required 1 parameter: <file path>');
WScript.Quit();
}
fname = objArgs(0);
str = '';
try {
var oFS = new ActiveXObject('Scripting.FileSystemObject');
var oFile = oFS.OpenTextFile(fname);
str = oFile.ReadAll();
oFile.Close();
} catch(e) {
WScript.StdOut.Write(statusUnknown + e.message+' ['+fname.replace(/\\\\/g,'\\')+']');
WScript.Quit;
}
WScript.StdOut.Write(statusOk + str);
|
Start cmd: cmd /c cscript /B /E:JScript %Script% %Params% |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Wed May 04, 2016 9:11 am Post subject: |
|
|
In most cases it's useless to display just file contents.
May be you need to check and compare value from file and set test status (Ok, Bad, etc..) depending on threshold value. |
|
Back to top |
|
|
Revro
Joined: 27 Apr 2016 Posts: 17
|
Posted: Mon May 09, 2016 1:34 am Post subject: |
|
|
Thanks for the Script
No, I need to read text, i don't need to compare it.
(Perhaps that my boss will change his opinion ; ) ) |
|
Back to top |
|
|
KS-Soft Europe
Joined: 16 May 2006 Posts: 2832
|
Posted: Mon May 09, 2016 6:56 am Post subject: |
|
|
You are welcome. |
|
Back to top |
|
|
|