Digital Developer Conference: a FREE half-day online conference focused on AI & Cloud – North America: Nov 2 – India: Nov 9 – Europe: Nov 14 – Asia Nov 23 Register now

Close outline
  • United States
IBM?
  • Site map
IBM?
  • Marketplace

  • Close
    Search
  • Sign in
    • Sign in
    • Register
  • IBM Navigation
IBM Developer Answers
  • Spaces
    • Blockchain
    • IBM Cloud platform
    • Internet of Things
    • Predictive Analytics
    • Watson
    • See all spaces
  • Tags
  • Users
  • Badges
  • FAQ
  • Help
Close

Name

Community

  • Learn
  • Develop
  • Connect

Discover IBM

  • ConnectMarketplace
  • Products
  • Services
  • Industries
  • Careers
  • Partners
  • Support
10.190.13.195

Refine your search by using the following advanced search options.

Criteria Usage
Questions with keyword1 or keyword2 keyword1 keyword2
Questions with a mandatory word, e.g. keyword2 keyword1 +keyword2
Questions excluding a word, e.g. keyword2 keyword1 -keyword2
Questions with keyword(s) and a specific tag keyword1 [tag1]
Questions with keyword(s) and either of two or more specific tags keyword1 [tag1] [tag2]
To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Do not use a plus or minus sign with a tag, e.g., +[tag1].
  • Ask a question

How can I set an output property from a shell step?

270007GVMD gravatar image
Question by MichelePegoraro  (37) | May 26, 2015 at 08:42 AM urbancodedeployucdhow-todoc-linkpropertiesoutputshell

Hi, I'd like to create an output property from a shell step in order to be used in a following step of a process. From the shell script I'd like to create the property.

Is it possible? How can I do this?

Thanks, Michele

People who like this

  0
Comment
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

2 answers

  • Sort: 
270007KTH0 gravatar image
Accepted answer

Answer by Moogly (43) | May 27, 2015 at 07:44 PM

You have to use the post processing script http://www-01.ibm.com/support/knowledgecenter/SS4GSP_6.0.1/com.ibm.udeploy.doc/topics/comp_postProcess.html?lang=en

Post Processing script will read the results from Shell and you can able to assign the values to property. In my case I have assigned the value in shell like "YourOutput=myValue10102455", then post processing script will read "YourOutput" string and assign

var exit = properties.get('exitCode');

scanner.register("regex", function(lineNumber, line) { var thing = 'do stuff'; });

if (exit == 0) { properties.put('Status', 'Success') scanner.register("^YourOutput", function(lineNumber, line) { var temp=line.split("="); var out=temp[1]; properties.put("YourPropertyName",out); }); scanner.scan(); } else { properties.put('Status', 'Failure'); }

Comment
Tim McMackin

People who like this

  1   Show 1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
270007GVMD gravatar image MichelePegoraro (37)   Jun 04, 2015 at 04:54 AM 0
Share

Thanks, it works!

270005SJFG gravatar image

Answer by Greg_P_SM (16) | Jun 01, 2015 at 12:01 PM

If you're open to using a Groovy script ("Run Groovy Script" step), you get access to inProps (input Properties) and outProps (output Properties). For example:

outProps.put("foo", "bar")

Primarily for use with shell scripts, I also have a post-processing script that extracts foo=bar from output:

 var i = 0;
 scanner.register("^[\\w\\-\\.]+=.+$", function(aLineNumber, aLine) {
   var parts = /^([\w\-\.]+)=(.+)$/.exec(aLine);
   if (parts == null || parts.length != 3) {
     properties.put("matchedScannerNotRegex" + i++, aLine);
   }
   else {
     properties.put(parts[1].trim(), parts[2].trim());
   }
 });
 
 properties.put("Status", (properties.get("exitCode") == 0 ? "Success" : "Failure"));
 
 scanner.scan();
Comment
MichelePegoraro

People who like this

  1   Share
10 |3000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster

Follow this question

34 people are following this question.

Answers

Answers & comments

Related questions

UrbanCode deploy: How to pass input properties into an application process 1 Answer

How to set up the approval process? 4 Answers

Is there a way to set an output variable from a shell script in a workflow? 1 Answer

How to store udclient command's output in a variable? 0 Answers

Is it possible to change System Settings from the command line or REST API? 1 Answer

  • Contact
  • Privacy
  • IBM Developer Terms of use
  • Accessibility
  • Report Abuse
  • Cookie Preferences

Powered by AnswerHub

Authentication check. Please ignore.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • API Connect
  • Analytic Hybrid Cloud Core
  • Application Performance Management
  • Appsecdev
  • BPM
  • Blockchain
  • Business Transaction Intelligence
  • CAPI
  • CAPI SNAP
  • CICS
  • Cloud Analytics
  • Cloud Automation
  • Cloud Object Storage
  • Cloud marketplace
  • Collaboration
  • Content Services (ECM)
  • Continuous Testing
  • Courses
  • Customer Experience Analytics
  • DB2 LUW
  • Data and AI
  • DataPower
  • Decision Optimization
  • DevOps Build
  • DevOps Services
  • Developers IBM MX
  • Digital Commerce
  • Digital Experience
  • Finance
  • Global Entrepreneur Program
  • Hadoop
  • Hybrid Cloud Core
  • Hyper Protect
  • IBM Cloud platform
  • IBM Design
  • IBM Forms Experience Builder
  • IBM Maximo Developer
  • IBM StoredIQ
  • IBM StoredIQ-Cartridges
  • IIDR
  • ITOA
  • InformationServer
  • Integration Bus
  • Internet of Things
  • Kenexa
  • Linux on Power
  • LinuxONE
  • MDM
  • Mainframe
  • Messaging
  • Node.js
  • ODM
  • Open
  • PartnerWorld Developer Support
  • PowerAI
  • PowerVC
  • Predictive Analytics
  • Product Insights
  • PureData for Analytics
  • Push
  • QRadar App Development
  • Run Book Automation
  • Search Insights
  • Security Core
  • Storage
  • Storage Core
  • Streamsdev
  • Supply Chain Business Network
  • Supply Chain Insights
  • Swift
  • UBX Capture
  • Universal Behavior Exchange
  • UrbanCode
  • WASdev
  • WSRR
  • Watson
  • Watson Campaign Automation
  • Watson Content Hub
  • Watson Marketing Insights
  • dW Answers Help
  • dW Premium
  • developerWorks Sandbox
  • developerWorks Team
  • Watson Health
  • More
  • Tags
  • Questions
  • Users
  • Badges