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.
|