cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Session ID using command line options

VictorC
Level 2
Hi All,
I tries to call the /getlog <sessionid> to get the log of the session using Command line options (AutomateC.exe), This function requires session id as a parameter,  Can you explain me how can I get the session id of the existing session ?

------------------------------
Victor C
Associate
Cognizant
Asia/Kolkata
------------------------------
3 REPLIES 3

DaveMorris
Level 14
As far as I know, the CLI commands cannot determine the session ID unless the session was started from command line using, for example, /run <processname>. That returns a session ID.


------------------------------
Dave Morris
3Ci at Southern Company
Atlanta, GA
------------------------------
Dave Morris 3Ci at Southern Company Atlanta, GA

ewilson
Staff
Staff
@VictorC,

If you know the specific runtime resource that's running the process you can use the HTTP interface and resource PC commands of the resource PC to get the active session ID.​ If you're on BP v7 or later, and you've deployed the REST API, you can use it to get session information.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

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

17560.png

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! 

17561.png

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