Solved

escape a newline character

Posted on 2006-06-26
7
1,747 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

24 Experts available now in Live!

Get 1:1 Help Now