SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
User_defined JAL running on Remote Server

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
User_defined JAL running on Remote Server
Author Message
Greg Johnson



Joined: 20 Oct 2001
Posts: 26

Post User_defined JAL running on Remote Server Reply with quote

I have created a user-defined JAL statement and stored it in the Script Library on the Master Scheduler. The job that contains the user_defined JAL needs to run on a Remote Agent. When the job executes on the Remote Server the error that I get is "Keyword not found". Is it possible to develop user-defined JAL statements and run them on Remote Servers. What I'm trying for is some way to have reusable code so that I don't have the same code in 20 scripts (some of the variable values within the script need to be changed so I need something that can pass parameters).

Fri Oct 19, 2001 6:52 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: User_defined JAL running on Remote Server Reply with quote

The job definition is automatically deployed to the Remote Agent before the job is executed. The Script Library is not! That's why you get "Keyword not found".

You have several options for dealing with this issue:
1. Add this statement to the Script Library on the Agent. Connect to the agent using the 24x7 Remote Control, and code the statement, then save the changes. After that you should be able to use it in remote jobs.

2. Store your common portion of the code in a file with .JAL extension and use @SCRIPT label in your scripts to include that file dynamically (it is a sort of #include directive in C/C++ and some other programming languages). This should work, as long as you use variable names consistently. You can also use global variables in your scripts to pass parameters between scripts. Such JAL file can be stored on a shared drive where all agents can "see" it.

3. If you run the main scheduler in the Master mode you can call its jobs from the agent, even recursively. For example, the master runs remote job on the Agent X, in that remote job you can use SetRemoteVariable statement to access/set variables on the master. You can also use RunRemoteJob to execute a auxilary job on the master that will access the same variables and change them as needed. Then you can use GetRemoteVariable in the remote job to obtain values of the variables on the master after the auxilary job is complete

4. Other workarounds are also available. If you provide more details on what you want to do, it may be easier to suggest a better solution cpecific to your situation.

: I have created a user-defined JAL statement and stored it in the Script
: Library on the Master Scheduler. The job that contains the user_defined
: JAL needs to run on a Remote Agent. When the job executes on the Remote
: Server the error that I get is "Keyword not found". Is it
: possible to develop user-defined JAL statements and run them on Remote
: Servers. What I'm trying for is some way to have reusable code so that I
: don't have the same code in 20 scripts (some of the variable values within
: the script need to be changed so I need something that can pass
: parameters).

Sat Oct 20, 2001 11:53 am View user's profile Send private message
Greg Johnson



Joined: 20 Oct 2001
Posts: 26

Post Re: User_defined JAL running on Remote Server Reply with quote

I like the off-line script solution which I am implementing. I am having a few problems putting together some of the code however.

My explanation might get a little messy with the code examples. I will try to organize this as clearly as possible.

1. Code Parts 1,2 and 3 are what I came up with for my solution.The IF statement in Code Part 3 causes either the Master Scheduler to go into an endless loop submitting this job over and over to the Remote Agent or it might be that the Remote Agent just keeps running the job in a infinite loop. The workaround was to come up with the code as shown in Code Part 4. To delete the log file I used the FILEDELETEEX statement instead of the FILEEXISTS coupled with the IF. I tried using the IF statement in the main job and it seemed to lock up the Master Scheduer but only ran the job once on the remote. I would deduce that the IF statement has problems when used in off-line scripts. Also see point 3 about line continuations.

2. My full solution is shown in Code Part 5. My first solution used this code which caused another looping condition :

If (global.DB2ScriptError, Errorfound, EndIt)

ErrorFound:

RaiseError "Backup failed - Check Remote Log File"

EndIt:

To fix this I used this code which seems to work:

IfThen (global.DB2ScriptError, Errorfound)

Exit

ErrorFound:

RaiseError "Backup failed - Check Remote Log File"

3. I was unable to use "&" for line continuation in the off-line scripts. They caused syntax errors upon exection.

4. The only last note is that off-line scrpts can be really tough or more time consuming to debug.

****Code Part 1******* Here is the JAL job that I execute from the Master Scheduler ********

// declare the global variables
@SCRIPT:x:\global_variables.jal

// run the database configuration listing
set (global.SQLScriptFileName, "finwhse_db_config")
set (global.DriveLetter, "d")
@SCRIPT:x:\DB2_run_DB2CLPEX.jal

****Code Part 2******** Here is the first SCRIPT (@SCRIPT:x:\global_variables.jal) ************
// Global Variables and Standard Settings

dim global.SQLScriptFileName, string
dim global.DriveLetter, string
dim global.JobScriptsFileDir, string
dim global.DB2cplexCmdFile, string
dim global.DB2ScriptError, boolean

// variables used for executing DB2CLPEX
dim global.CmdStr, string
dim global.SqlStr, string
dim global.LogStr, string

set (global.JobScriptsFileDir, "job_scripts")
set (global.DB2cplexCmdFile, "db2clpex_with_log.cmd")
set (global.DriveLetter, "d")

****Code Part3******** Here is the second SCRIPT (@SCRIPT:x:\DB2_run_DB2CLPEX.jal) ************
// Run DB2CPLEX with requested SQL file and produce log file

// Define local varuables
dim processid, number
dim filefound, boolean
dim RunString, string

// Set up the DOS command line to execute a CMD file that will execute DB2CLPEX.
//
// There are 3 files taht need to be defined:
// 1. The CMD file that will run DB2CLPEX. This file resides on the
// Remote Agent.
// 2. The SQL file that DB2CLPEX will run. This file resides on the
// Remote Agent.
// 3. The LOG file. This will actually be the listing for the database
// configuration.
// It is the output of "DB2 get db config"
//
// There 3 parts to each file because of the different setup of the DB2 servers.
//.The variables are defined at the global level and are:
// 1. The drive letter where the job scripts reside.
// 2. The file directory where the job scripts reside.
// 3. The file name.
//
ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir, "\\", global.DB2cplexCmdFile, global.CmdStr)
ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir, "\\", global.SQLScriptFileName, ".sql", global.SqlStr)
ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir, "\\", global.SQLScriptFileName, ".log", global.LogStr)
ConcatEx (global.CmdStr, " ", global.SqlStr, " ", global.LogStr, RunString)

//If the log file exists then delete it before the new run
set (LogFile, global.LogStr)
FileExists(global.LogStr, filefound)
If(filefound, DeleteLogFile, RunDB2CLPEX)

DeleteLogFile:

FileDelete global.LogStr
// Debug display to the 24x7 log

LogAddMessageEx ("INFO", 0, "Debug Display", "Log file Deleted")

RunDB2CLPEX:
// Debug display to the 24x7 log
LogAddMessageEx ("INFO", 0, "Debug Display", RunString)

RunAndWait (RunString, "", "", processid)

****Code Part4******** Fix/Workaround for Code Part 3************
// Run DB2CPLEX with requested SQL file and produce log file

// Define local varuables
dim processid, number
dim RunString, string
dim FilesDeleted, number
dim DeleteFile, string

// Set up the DOS command line to execute a CMD file that will execute DB2CLPEX.
//
// There are 3 files taht need to be defined:
// 1. The CMD file that will run DB2CLPEX. This file resides on the
// Remote Agent.
// 2. The SQL file that DB2CLPEX will run. This file resides on the
// Remote Agent.
// 3. The LOG file. This will actually be the listing for the database
// configuration.
// It is the output of "DB2 get db config"
//
// There 3 parts to each file because of the different setup of the DB2 servers.
//.The variables are defined at the global level and are:
// 1. The drive letter where the job scripts reside.
// 2. The file directory where the job scripts reside.
// 3. The file name.
//
ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir, "\\", global.DB2cplexCmdFile, global.CmdStr)
ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir, "\\", global.SQLScriptFileName, ".sql", global.SqlStr)
ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir, "\\", global.SQLScriptFileName, ".log", global.LogStr)
ConcatEx (global.CmdStr, " ", global.SqlStr, " ", global.LogStr, RunString)

//Delete the log file

ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir, "\\", global.SQLScriptFileName, ".lo?", DeleteFile)

FileDeleteEx (DeleteFile, FilesDeleted)
// Debug display to the 24x7 log

LogAddMessageEx ("INFO", 0, "Debug Display", "Log file Deleted")

//RunDB2CLPEX:
// Debug display to the 24x7 log
LogAddMessageEx ("INFO", 0, "Debug Display", RunString)

RunAndWait (RunString, "", "", processid)

****Code Part 5******** Final solution - JAL job that I execute from the Master Scheduler ************
// declare the global variables
@SCRIPT:x:\global_variables.jal
set (global.DriveLetter, "d")

// run the database configuration listing
set (global.SQLScriptFileName, "finwhse_db_config")
@SCRIPT:x:\DB2_run_DB2CLPEX.jal

// run the database backup
set (global.SQLScriptFileName, "finwhse_bkup")
@SCRIPT:x:\DB2_run_DB2CLPEX.jal

// check for errors
@SCRIPT:x:\DB2_Script_Error_Check.jal

// report Errors if any
IfThen (global.DB2ScriptError, Errorfound)
Exit

ErrorFound:
RaiseError "Backup failed - Check Remote Log File"

: The job definition is au tomatically deployed to the Remote Agent before the
: job is executed. The Script Library is not! That's why you get
: "Keyword not found".

: You have several options for dealing with this issue: 1. Add this statement
: to the Script Library on the Agent. Connect to the agent using the 24x7
: Remote Control, and code the statement, then save the changes. After that
: you should be able to use it in remote jobs.

: 2. Store your common portion of the code in a file with .JAL extension and
: use @SCRIPT label in your scripts to include that file dynamically (it is
: a sort of #include directive in C/C++ and some other programming
: languages). This should work, as long as you use variable names
: consistently. You can also use global variables in your scripts to pass
: parameters between scripts. Such JAL file can be stored on a shared drive
: where all agents can "see" it.

: 3. If you run the main scheduler in the Master mode you can call its jobs
: from the agent, even recursively. For example, the master runs remote job
: on the Agent X, in that remote job you can use SetRemoteVariable statement
: to access/set variables on the master. You can also use RunRemoteJob to
: execute a auxilary job on the master that will access the same variables
: and change them as needed. Then you can use GetRemoteVariable in the
: remote job to obtain values of the variables on the master after the
: auxilary job is complete

: 4. Other workarounds are also available. If you provide more details on what
: you want to do, it may be easier to suggest a better solution cpecific to
: your situation.

Tue Oct 23, 2001 10:23 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: User_defined JAL running on Remote Server Reply with quote

First off all I would like to thank you for your valuable feedback.

Here are my comments.

1. Yes, you are right, you should avoid using IF, CHOOSECASE, LOOPWHILe, LOOPUNTIL, and FORNEXT constructs that begin or end in the off-line script, but go beyond it, the script engine validates them before actually executing the script and inserting the off-line part. As a result, it leads to syntax error. Please consider this as limitation for off-line scripts.

2. You may need to add EXIT after RAISEERROR if the job has "ignore errors" option set on.

3. This sounds as a clear bug. I am submitting it to the "to be fixed" list

4. I find tracing option in Tools/Options/Log/Trace Enabled very helpful for such debugging. The complete trace of the script including off-line parts are written to the script.log file. The drawback, the log is overwritten on each run.

: I like the off-line script solution which I am implementing. I am having a
: few problems putting together some of the code however.

: My explanation might get a little messy with the code examples. I will try to
: organize this as clearly as possible.

: 1. Code Parts 1,2 and 3 are what I came up with for my solution.The IF
: statement in Code Part 3 causes either the Master Scheduler to go into an
: endless loop submitting this job over and over to the Remote Agent or it
: might be that the Remote Agent just keeps running the job in a infinite
: loop. The workaround was to come up with the code as shown in Code Part 4.
: To delete the log file I used the FILEDELETEEX statement instead of the
: FILEEXISTS coupled with the IF. I tried using the IF statement in the main
: job and it seemed to lock up the Master Scheduer but only ran the job once
: on the remote. I would deduce that the IF statement has problems when used
: in off-line scripts. Also see point 3 about line continuations.

: 2. My full solution is shown in Code Part 5. My first solution used this code
: which caused another looping condition : If (global.DB2ScriptError,
: Errorfound, EndIt)

: ErrorFound: RaiseError "Backup failed - Check Remote Log File"

: EndIt: To fix this I used this code which seems to work: IfThen
: (global.DB2ScriptError, Errorfound)

: Exit

: ErrorFound: RaiseError "Backup failed - Check Remote Log File"

: 3. I was unable to use "&" for line continuation in the off-line
: scripts. They caused syntax errors upon exection.

: 4. The only last note is that off-line scrpts can be really tough or more
: time consuming to debug.

: ****Code Part 1******* Here is the JAL job that I execute from the Master
: Scheduler ********

: // declare the global variables
: @SCRIPT:x:\global_variables.jal

: // run the database configuration listing
: set (global.SQLScriptFileName, "finwhse_db_config")
: set (global.DriveLetter, "d")
: @SCRIPT:x:\DB2_run_DB2CLPEX.jal

: ****Code Part 2******** Here is the first SCRIPT
: (@SCRIPT:x:\global_variables.jal) ************
: // Global Variables and Standard Settings

: dim global.SQLScriptFileName, string
: dim global.DriveLetter, string
: dim global.JobScriptsFileDir, string
: dim global.DB2cplexCmdFile, string
: dim global.DB2ScriptError, boolean

: // variables used for executing DB2CLPEX
: dim global.CmdStr, string
: dim global.SqlStr, string
: dim global.LogStr, string

: set (global.JobScriptsFileDir, "job_scripts")
: set (global.DB2cplexCmdFile, "db2clpex_with_log.cmd")
: set (global.DriveLetter, "d")

: ****Code Part3******** Here is the second SCRIPT
: (@SCRIPT:x:\DB2_run_DB2CLPEX.jal) ************
: // Run DB2CPLEX with requested SQL file and produce log file

: // Define local varuables
: dim processid, number
: dim filefound, boolean
: dim RunString, string

: // Set up the DOS command line to execute a CMD file that will execute
: DB2CLPEX.
: //
: // There are 3 files taht need to be defined: // 1. The CMD file that will
: run DB2CLPEX. This file resides on the
: // Remote Agent.
: // 2. The SQL file that DB2CLPEX will run. This file resides on the
: // Remote Agent.
: // 3. The LOG file. This will actually be the listing for the database
: // configuration.
: // It is the output of "DB2 get db config"
: //
: // There 3 parts to each file because of the different setup of the DB2
: servers.
: //.The variables are defined at the global level and are: // 1. The drive
: letter where the job scripts reside.
: // 2. The file directory where the job scripts reside.
: // 3. The file name.
: //
: ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir,
: "\\", global.DB2cplexCmdFile, global.CmdStr)
: ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir,
: "\\", global.SQLScriptFileName, ".sql", global.SqlStr)
: ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir,
: "\\", global.SQLScriptFileName, ".log", global.LogStr)
: ConcatEx (global.CmdStr, " ", global.SqlStr, " ",
: global.LogStr, RunString)

: //If the log file exists then delete it before the new run
: set (LogFile, global.LogStr)
: FileExists(global.LogStr, filefound)
: If(filefound, DeleteLogFile, RunDB2CLPEX)

: DeleteLogFile: FileDelete global.LogStr
: // Debug display to the 24x7 log

: LogAddMessageEx ("INFO", 0, "Debug Display", "Log
: file Deleted")

: RunDB2CLPEX: // Debug display to the 24x7 log
: LogAddMessageEx ("INFO", 0, "Debug Display", RunString)

: RunAndWait (RunString, "", "", processid)

: ****Code Part4******** Fix/Workaround for Code Part 3************
: // Run DB2CPLEX with requested SQL file and produce log file

: // Define local varuables
: dim processid, number
: dim RunString, string
: dim FilesDeleted, number
: dim DeleteFile, string

: // Set up the DOS command line to execute a CMD file that will execute
: DB2CLPEX.
: //
: // There are 3 files taht need to be defined: // 1. The CMD file that will
: run DB2CLPEX. This file resides on the
: // Remote Agent.
: // 2. The SQL file that DB2CLPEX will run. This file resides on the
: // Remote Agent.
: // 3. The LOG file. This will actually be the listing for the database
: // configuration.
: // It is the output of "DB2 get db config"
: //
: // There 3 parts to each file because of the different setup of the DB2
: servers.
: //.The variables are defined at the global level and are: // 1. The drive
: letter where the job scripts reside.
: // 2. The file directory where the job scripts reside.
: // 3. The file name.
: //
: ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir,
: "\\", global.DB2cplexCmdFile, global.CmdStr)
: ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir,
: "\\", global.SQLScriptFileName, ".sql", global.SqlStr)
: ConcatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir,
: "\\", global.SQLScriptFileName, ".log", global.LogStr)
: ConcatEx (global.CmdStr, " ", global.SqlStr, " ",
: global.LogStr, RunString)

: //Delete the log file

: Co ncatEx (global.DriveLetter, ":\\", global.JobScriptsFileDir,
: "\\", global.SQLScriptFileName, ".lo?", DeleteFile)

: FileDeleteEx (DeleteFile, FilesDeleted)
: // Debug display to the 24x7 log

: LogAddMessageEx ("INFO", 0, "Debug Display", "Log
: file Deleted")

: //RunDB2CLPEX: // Debug display to the 24x7 log
: LogAddMessageEx ("INFO", 0, "Debug Display", RunString)

: RunAndWait (RunString, "", "", processid)

: ****Code Part 5******** Final solution - JAL job that I execute from the
: Master Scheduler ************
: // declare the global variables
: @SCRIPT:x:\global_variables.jal
: set (global.DriveLetter, "d")

: // run the database configuration listing
: set (global.SQLScriptFileName, "finwhse_db_config")
: @SCRIPT:x:\DB2_run_DB2CLPEX.jal

: // run the database backup
: set (global.SQLScriptFileName, "finwhse_bkup")
: @SCRIPT:x:\DB2_run_DB2CLPEX.jal

: // check for errors
: @SCRIPT:x:\DB2_Script_Error_Check.jal

: // report Errors if any
: IfThen (global.DB2ScriptError, Errorfound)
: Exit

: ErrorFound: RaiseError "Backup failed - Check Remote Log File"

Tue Oct 23, 2001 2:18 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 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
Design by Freestyle XL / Flowers Online.