Jump to content

Need help on JavaScripting


Recommended Posts

I do not know Javascript. I know some Java but mostly I am a mainframe coding programmer. I am working on an issue at work. We are processing Sybase database deployments. The scripts come in as txt files with 1 txt file containing 1 deployment. During the deployment a log file is generated which is displayed below. The log file can determine what has been processed and what has been error out. I have some code below that I believe puts the line information in a array. I need to determine what script processed successfully and what script errored out. I then need to out put both files to txt or sql files. If 10 scripts were processed and script 5 err out theprocessed output file would have to be in the format of 
sybase1.txt
sybase2.txt
sybase3.txt
sybase4.txt

The error output file would have 
sybase5.txt 

The code below does not extract the file name and its only a start.

properties.put("Status", "Success");

if (properties.get("exitCode") != 0) {
properties.put("Status", "Failure");
}
else {
var line= ' ' 
scanner.register("(?i)Fail to Exeute", function(lineNumber, line) {
var errors = properties.get("Fail");
if (errors == null) {
errors = new java.util.ArrayList();
}
errors.add(line);
properties.put("Status", "Failure");
});
var processed = properties.get("Executing Resource");
if (processed == null) {
processed = new java.util.ArrayList();
}
processed.add(line);
scanner.scan();
var errors = properties.get("Error");
if (errors == null) {
errors = new java.util.ArrayList();
}
properties.put("Error", errors.toString());
var processed = properties.get("Executing Resource");
if (processed == null) {
processed = new java.util.ArrayList();
}
properties.put("Executing Resource", processed.toString());
}

LOG FILE (There is a line number sequence on the left that did not copy)
1

Executing resource: /var/serena/work/VAN_Sybase/sybase7.txt   (this script was a success)2 [sql] ,3 [sql] pass 3,244 [sql] 0 rows affected5 [sql] Failed to execute: 'pass 1', @@servername, db_name(), getdate() 6 [sql] Executing resource: /var/serena/work/VAN_Sybase/sybase8.txt  (this script errred out)7Error Executing SQL Scripts: com.sybase.jdbc4.jdbc.SybSQLException: Incorrect syntax near','.
 

So I would need 1 file containing

sybase7.txt

and 1 file containing

sybase8.txt

Any help on this would be awesome. thanks!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...