[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 900
  • Last Modified:

new line character in batch

I have to pass a newline character in a batch script and pipe it to another command how can I achieve this ?
0
shadow2007
Asked:
shadow2007
2 Solutions
 
Bill PrewCommented:
Need a little more information on what the data you need to pipe is, and what the program involved are, etc.  For example, the following will work fine and will send a line feed between the two lines to the next program, in this example just MORE.  But need to understand you specifics better to know if this could work or not.

@echo off
(
  echo Line 1
  echo Line 2
) | more

Open in new window

~bp
0
 
Steve KnightIT ConsultancyCommented:
You could also I suppose mean just how to get a blank line which is:

@echo off
echo Line 1
echo.
echo Line 3

etc.

But like Bill says, tell us more!

Steve
0
 
shadow2007Author Commented:
working with networker and trying to feed nsradmin utility the required data
for example

echo create type: NSR Directive; Name: Test;
directive: << / >>
compressasm: *.?*
<< "D:\" >>
+skip: test;
| nsradmin -i-

each row needs to be like that and I need to feed nsradmin
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
Steve KnightIT ConsultancyCommented:
You'll have to a bit of escaping with those >> and << chars but something like this will probably do it:

(echo create type: NSR Directive; Name: Test;
echo directive: ^<^< / ^>^>
echo compressasm: *.?*
echo ^<^< "D:\" ^>^>
echo +skip: test;
) | nsradmin -i-

Steve
0
 
Bill PrewCommented:
Since it doesn't look like there is any variable data why not just create a seperate TXT file with those lines in it, and then run like this.

nsradmin -i- <lines.txt

~bp
0
 
QlemoC++ DeveloperCommented:
Agree to Bill's suggestion. Another way is to use some kind of "here string", which allows to have it all in a single file cmd file:
@echo off
for /F "delims=[]" %%N in ('find /N ":: StartOfTxt" ^< %~f0') do set startline=%%N
(for /F "skip=%startline% delims=" %%L in (%~f0) do echo.%%L) 

exit /b

:: StartOfTxt
create type: NSR Directive; Name: Test; 
directive: << / >>
compressasm: *.?*
<< "D:\" >>
+skip: test;

Open in new window

0
 
Bill PrewCommented:
Thanks, glad that helped.

~bp
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now