Difference between revisions of "Script to Read Files"

From Observer GigaFlow Support | VIAVI Solutions Inc.
Jump to: navigation, search
 
Line 1: Line 1:
var InputStreamReader= Java.type('java.io.InputStreamReader');
+
var InputStreamReader= Java.type('java.io.InputStreamReader');
var BufferedReader = Java.type('java.io.BufferedReader');
+
var BufferedReader = Java.type('java.io.BufferedReader');
var FileReader = Java.type('java.io.FileReader');
+
var FileReader = Java.type('java.io.FileReader');
var utils = Java.type('ros.CROSUtils');
+
var utils = Java.type('ros.CROSUtils');
var now = new Date()
+
var now = new Date()
log.warn("start")
+
log.warn("start")
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
+
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Decr"
+
  "Jul", "Aug", "Sep", "Oct", "Nov", "Decr"
];
+
];
 
+
try {
try {
+
 
var areader = objReader = new BufferedReader(new FileReader("/opt/ros/resources/webapps/static/syslog.txt"));
 
var areader = objReader = new BufferedReader(new FileReader("/opt/ros/resources/webapps/static/syslog.txt"));
 
var line = null;
 
var line = null;
Line 20: Line 19:
 
       log.warn(thisone.join(" "))
 
       log.warn(thisone.join(" "))
 
}
 
}
} catch ( e) {
+
} catch ( e) {
 
   areader.close()
 
   areader.close()
}
+
}
log.warn("end")
+
log.warn("end")

Latest revision as of 13:17, 16 May 2022

var InputStreamReader= Java.type('java.io.InputStreamReader');
var BufferedReader = Java.type('java.io.BufferedReader');
var FileReader = Java.type('java.io.FileReader');
var utils = Java.type('ros.CROSUtils');
var now = new Date()
log.warn("start")
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Decr"
];
try {

var areader = objReader = new BufferedReader(new FileReader("/opt/ros/resources/webapps/static/syslog.txt")); var line = null; while ((line = areader.readLine()) != null) {

     	log.warn(line)
       var thisone = line.split(" ");	
     	thisone[0]=monthNames[now.getMonth()]
       thisone[1]=now.getDate()
       thisone[2]=now.getHours()+":"+now.getMinutes()+":"+now.getSeconds()
     	log.warn(thisone.join(" "))

}

} catch ( e) {
 areader.close()
}
log.warn("end")