Solved

escape a newline character

Posted on 2006-06-26
7
1,748 Views
Last Modified: 2010-07-27
I'm constructing a statement that the Window's command shell passes on to an application.  As part of that statement, I need to include a newline.  I need that newline not to terminate the statement, but to be passed along to the application.  I know that I can escape some special characters with a backslash.  But, how can I escape a newline?

Here is a simplified example of the issue.  -a, -b, -c are flags that signal the meaning of the following parameter information (embedded in double quotes).

c:\myexe.exe -a "a quoted sequence of information" -b "a quoted sequence that has a double quote embedded in it (\"), escaped with a backslash" -c "a quoted sequence that needs a <NEWLINE> that allows the quoted sequence to continue"

To get a double-quote (parameter -b), I just have to do: \".  What is the equivalent for a newline?

Thanks.
0
Comment
Question by:dannykrouk
7 Comments
 
LVL 10

Expert Comment

by:For-Soft
ID: 16989989
As far as I know, there is no global "special character" you can use.

The program has to support special character formatting, and it will have own special haracter definitions, probably.
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 125 total points
ID: 16990561
When you say newline is it looking for a line feed (10) carriage return (13) or both?  You might be able to do this using EDIT

Enter Control P then press Control M for ASCII 13 (carriage return) and it inserts a small character.

How the program will handle this I don't know but it does to appear to work in that DOS still sees it as one line.

0
 
LVL 14

Expert Comment

by:cwwkie
ID: 16994944
> -c "a quoted sequence that needs a <NEWLINE> that allows the quoted sequence to continue"

Can't you use something like -c "file:input.txt", and in your exe, read the file input.txt?
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 43

Expert Comment

by:Steve Knight
ID: 17006897
Did it work?  Why the B grade because you ask something that IMHO is not possible though I gave you a way of getting a CR into the commandline, whether it works for your app I don't know of course.
0
 

Author Comment

by:dannykrouk
ID: 17010291
Yes, it did work.  I gave you a "B" because I did not read the Answer Grading guidelines carefully.  You deserve an "A".  I'm contacting a moderator to ask that the grade be upgraded.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17013725
Thankyou, appreciated.  

Steve
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question