It is possible to get the session id. But we have to use a BP Action to make it happen. The session ID is returned as part of the standard output when a command line is run from a BP Process. Here is something that I have working because we use this system to run processes that are listed in a specific order in a configuration file. I'm posting this here as it may help the community.
Step 1: Run this command line using the "Utility - Environment::Start Process Read Stderr and Stdout" . Here is an example command from my DEV setup:
"/run ""Simple Child Process 1"" /resource MACHINE_NAME /user BP_User_Name BP_Password /startp ""<inputs> <input name='Text Parameter' type='text' value='" & [Text Param 1] & "' /><input name='Numeric Parameter' type='number' value='" & [Num Param 2] & "' /></inputs>"""
This action returns command line output into two output variables Standard Output and Standard Error. Map these two variables to standard BP Data items. Once the command runs successfully, the Standard Output data item will have an output that typically looks like this and contains the session id of the target process:
Started process:Simple Child Process 1
Resource: MACHINE_NAME
Actual resource: MACHINE_NAME
Session:1c778a54-1af6-4eab-a772-20687af0ab11
Step 2: Extract the Session ID using the RegEx utility (or string parsing) into a local variable. It would be safe to add a Trim(SESSION_ID) to remove the trailing line break. Otherwise you will be spending hours trying to figure out why subsequent command lines don't work!
The next step is to confirm that you process has completed before calling /getlog
Step 3: In this case, I set up a Decision Loop with a timeout to wait for the Session status to go from "Running" to "Completed"
Again, I use the "Utility - Environment::Start Process Read Stderr and Stdout" to run this following command line and fetch the session status:
"/status " & Trim([SESSION_ID]) & " /user BP_User_Name BP_Password"
As before, extract the sessions status using RegEx. Break the loop when the status changes from "Running" to "Completed" (or when it times out in which case it's a failure scenario).
Step 4: Finally, use the /getlog switch to get the log from the session ID like so:
"/getlog " & Trim([Session ID]) & " /user BP_User_Name BP_Password "
Something to note:
It may be an issue with my BP installation. The /getlog in my case is unable to return the output parameters returned by the target process. Instead it just outputs simple log lines. I have raised a ticket with BP to address this issue.
Thanks and I hope this helps.
-Andy
------------------------------
Prashanth (Andy) Menon
------------------------------