At this time there are three options (documented below). An enhancement idea/request has also been created. You can find and vote for it here: Get output variable(s)/value(s) from windows/unix jobs similar to stored procedure output variables.
Option 1:
Use the Text File Reading and Monitoring job and WOB._lstatus to return the line/data.
Example:
- Define an Alert as follows:
- setVar('status',WOB._lstatus);
- setVar('symstatus',APPL.status);
- Run the Windows (or Unix) job that generates the output. Example:
Command: powershell.exe
Arguments: -Command & {Write-Host "This is a test `r`nThis isnt a test"}
Note: If the command generates the output to stdout then configure the Environment Variables with a variable:
- Name: STDOUT
- Value: Path_to_file
- Configure the Text File Reading and Monitoring Job to search the file for the data you want.
Other Monitor Parameters: Return immediately
Notifications:
- Deselect "Use Application-level defaults"
- Create a New Alert with Monitor State "Complete" selected. Select the Alert from step 1 in the "Alert name" drop down.
- In the next job where you want to use this information, use the following javascript to access/utilize the data:
APPL.status1=getVar('status');
var temp= APPL.status1.split(":");
var value=temp[1];
Based on the above, you can then use %APPL.status1 or %value to access the information picked up from the Text File Reading and Monitoring Job.
Option 2:
Write the output of the Windows job to a network drive that the DSeries server can access via javascript.
Con: Need to have a shared drive location to temporarily store the output data.
Example:
- Run the Windows (or Unix) job that generates the output (and stdout output file in this case). Example:
Command: powershell.exe
Arguments: (Get-Content "D:\path\to\data\file.txt" | Select -First 3 | Select -Last 1).Substring(12,10) | Out-File -filepath "\\unc|nfs\path\to\output_file.txt" -Encoding utf8
- Then, in the next action, read using the output file of action 1 - using the following javascript:
if (file_exist('/unc|nfs/path/to/output_file.txt'))
{
APPL.lineCount = file_getLineCount('/unc|nfs/path/to/output_file.txt');
}
if (APPL.lineCount != 0)
{
APPL.filedatelines = file_readLines('/unc|nfs/path/to/output_file.txt',0,1);
APPL.filedate = APPL.filedatelines[0];
}
- This makes the js variable APPL.filedate populated that can be used by subsequent jobs.
Option 3:
Use the server cli to setvar to redirect output (via an environment variable) to a Global Variable. Then, use the value in the Global Variable.
Con: The cli component would need to be installed on each agent where this needs to be done.
Example:
- Run the Unix (or Windows) job that generates the output. Example:
Command: /bin/bash
Arguments: -c "tail -n1 /opt/wade123/de/deserver/logs/tracelog.txt | cut -d' ' -f1-2"
Environment Variables: Name: STDOUT, Value: /tmp/s3job
- Run the Unix (or Windows) job that calls the cli to use setvar. Example:
Command: /opt/wade123/de/deserver/bin/cli
Arguments: <name of your wade server> 7500 <user> <pass> 'setvar name("s3var") value("'$(cat /tmp/s3job)'")'
- Run the Unix (or Windows) job that uses the global variable. Example:
Javascript: APPL.mys3var=getVar('S3VAR','DEFAULT');
Command: /bin/bash
Arguments: APPL.mys3var=getVar('S3VAR','DEFAULT');