KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Read text file and display text

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting
View previous topic :: View next topic  
Author Message
Revro



Joined: 27 Apr 2016
Posts: 17

PostPosted: Wed May 04, 2016 8:45 am    Post subject: Read text file and display text Reply with quote

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
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed May 04, 2016 9:07 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed May 04, 2016 9:11 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Revro



Joined: 27 Apr 2016
Posts: 17

PostPosted: Mon May 09, 2016 1:34 am    Post subject: Reply with quote

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
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Mon May 09, 2016 6:56 am    Post subject: Reply with quote

You are welcome.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Configuration, Maintenance, Troubleshooting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index