Reputation: 284
Hi I'm trying to write a file that will have arguments for an exec (putty) The problem is that the line feed trick is not working, how can i put a carriage return after each line avoiding the batch to interprets it as an enter.
set LF=^
set previousver=36
SET base=%fullver:1.2.0
set out=features:uninstall NOCFileLookup !LF
removeurl:mvn:org.NOC/NOCFileLookup-feature/%base%.%previousver%-SNAPSHOT/xml !LF
addurl mvn:org.NOC/NOCFileLookup-feature/1.2.0.37-SNAPSHOT/xml !LF
features:install NOCFileLookup!LF
config:edit NOCFileLookup !LF
config:propset context Testing !LF
config:update
@echo %out% > deployALL
start C:\"Program Files (x86)"\PuTTY\putty.exe -ssh localhost -l karaf -pw karaf -P 8101 -m deployAll
Upvotes: 1
Views: 2064
Reputation: 24466
The set LF=^
trick needs two blank lines following to work. Also, the syntax for retrieving a batch variable in the delayed expansion style is to use an exclamation mark on both sides of the variable name. See https://stackoverflow.com/a/28992360/1683264 for an example of correct implementation of what you're trying to do.
But really, you're making more work for yourself. Why must all lines be combined into a single variable with included line breaks? The batch language isn't terribly welcoming for multi-line variable values the way JavaScript and other languages are. If all you're doing is echoing several lines to a text file, then use several echo
statements.
>deployAll (
echo features:uninstall NOCFileLookup
echo removeurl:mvn:org..NOC/NOCFileLookup-feature/%base%.%previousver%-SNAPSHOT/xml
echo addurl mvn:org.NOC/NOCFileLookup-feature/1.2.0.37-SNAPSHOT/xml
echo features:install NOCFileLookup
echo config:edit NOCFileLookup
echo config:propset context Testing
echo config:update
)
Now isn't that much more readable?
Upvotes: 4