Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

Cisco Employee

How to get variable from script in CPO.

HI,

I am storing a output in a variable inside a script.

 

I want to access the output variable in the process.

 

How to use the variable defined inside the script in CPO.

1 ACCEPTED SOLUTION

Accepted Solutions

I assume you are talking

I assume you are talking about either PowerShell script (Execute Windows PowerShell Scrtipt activity) or a VBScript  (Execute Windows Script activity). In both cases, the only way to pass the data out is to send it to standard output and then to refer to the "Output" property of the activity in the subsequent activities where you need to use it.

If needed you can define a variable (a global variable, or a process output/local variable or a target property) and save the Output property of the script activity into that variable using Set Variable activity.

3 REPLIES

I assume you are talking

I assume you are talking about either PowerShell script (Execute Windows PowerShell Scrtipt activity) or a VBScript  (Execute Windows Script activity). In both cases, the only way to pass the data out is to send it to standard output and then to refer to the "Output" property of the activity in the subsequent activities where you need to use it.

If needed you can define a variable (a global variable, or a process output/local variable or a target property) and save the Output property of the script activity into that variable using Set Variable activity.

Cisco Employee

Thank you so much for your

Thank you so much for your reply.

 

Can you please tell me how to extract only the needed part from the standard output to a variable.

The answer is "it depends".If

The answer is "it depends".

If you can limit the output of your script to JUST the value you are interested in, then there is no need for any kind of parsing. You can simply refer to the "Workflow.ScriptActivity.Output" property and use it as is.

If your script produces lots of output, the parsing will depend on the output produced, wouldn't it?

You could also write the variable you are interested in a "file", and then simply read the file in a different activity.

If you have control over the script then you should consider the fact that it is much easier to parse "structured" text, such as XML, JSON, HTML, or CSV output. So, you could consider refactoring your script to produce "structured" output and then using one of the builtin Orchestrator activities (such as XPath Query, XSL Transform, JSON to XML or Read Table) to parse the Output property of the Windows Script activity into the appropriate format.

171
Views
0
Helpful
3
Replies
CreatePlease to create content