Read text file and display text

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
Revro
Posts: 17
Joined: Wed Apr 27, 2016 6:43 am

Read text file and display text

Post by Revro »

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.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You may use Shell Script test with simple JS script:

Code: Select all

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%
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

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.
Revro
Posts: 17
Joined: Wed Apr 27, 2016 6:43 am

Post by Revro »

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 ; ) )
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

You are welcome.
Post Reply