Removing the Newline Character from Execute Script/Batch File and Execute Command Actions' stdout
SummaryHow to remove the newline or carriage return character from $EXECUTE_STDOUT$ for Execute Script/Batch File and Execute Command Actions.
SynopsisWhen running an Execute Script/Batch File action or an Execute Command action, the STDOUT value will be returned with a newline character appended to the end of the string. This newline character may be unwanted when stored in an InstallAnywhere variable. The steps outlined below provide a way to remove the newline character from the variable's value.
DiscussionTo remove a newline character as well as any white spaces from the beginning and end of a string, a Custom Code action can be used. The steps below uses the ModifyString Custom Code action available from Flexera Software's website: InstallAnywhere Custom Code Extensions
- Download the ModifyString extension.
- Add a Set InstallAnywhere Variable action and set $MS_STRING_TO_CONVERT$ to the variable that contains the string with a newline character (i.e. $MS_STRING_TO_CONVERT$ = $EXECUTE_STDOUT$).
- Follow the General Instructions in the ModifyString.htm to implement the custom action.
- Use the $MS_STRING_TRIM$ output variable that gets set by the ModifyString action to obtain the new string value with the newline character removed.
Additional InformationWhen executing a command that prevents a newline character from being created, such as the following on Linux:
echo -n $variablea newline character is still added to the string stored in the $EXECUTE_STDOUT$ InstallAnywhere variable set by the action. An enhancement request has been submitted to our Engineering team as Issue# IOA-000066612 to address this. Our Engineering team is investigating this issue, but at this moment, there is no estimated time frame for when a fix will be implemented.