Solved

escape a newline character

Posted on 2006-06-26
7
1,746 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now