- Community Home
- >
- Software
- >
- HPE Morpheus Software
- >
- HPE Morpheus Enterprise
- >
- Using conditional statement in shell tasks with ch...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 03:53 AM
02-21-2023 03:53 AM
Using conditional statement in shell tasks with checkbox as custom option
Without if statement
In the example below, we have a shell script task with a variable ‘checkStatus’. The value of ‘checkStatus’ will be either ‘on’ when checked, or ‘off’ when unchecked.
checkStatus="<%= customOptions.cluster_checkbox %>"
echo "myVal = $checkStatus"
Using if statement
But on the following task we are using an if statement to set the value of ‘checkStatus’. In this case when the checkbox is checked the value will be ‘on’. But if the checkbox is unchecked the value will not be empty string or ‘off’, but ‘null’.
checkStatus="<%= if (customOptions.cluster_checkbox == 'on') { 'on' } %>"
echo "checkStatus = $checkStatus"
When using if statement as shown above, you must specify the value to return when the checkbox is unchecked. Otherwise, it will just return null. On the example below we are also including an ‘else’ statement to return ‘off’ when unchecked.
checkStatus="<%= if (customOptions.cluster_checkbox == 'on') { 'on' } else { 'off' }%>"
echo "checkStatus = $checkStatus"