How to output 1 Double Quote to a text file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
phlex7
Posts: 5
Joined: 03 Aug 2014 07:53

How to output 1 Double Quote to a text file

#1 Post by phlex7 » 03 Aug 2014 08:09

Good Morning All;

I'm trying to output the following text to a .txt file but I'm getting errors because of the single Quote in each line.

Code: Select all

SYSOPTS="'DSN=OPO.NDMD.SUBMIT(PEGFIS00),DISP=SHR', -
'PARM1 '~'&FAF'~''"


This is my output command:

Code: Select all

Echo.      SYSOPTS="'DSN=OPO.NDMD.SUBMIT(PEGFIS00),DISP=SHR', - > C:\mytext.txt
Echo. 'PARM1 '~'&FAF'~''" >> C:\mytext.txt


Is there a way to do this?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to output 1 Double Quote to a text file

#2 Post by foxidrive » 03 Aug 2014 08:48

The problem is more likely to be the & character which is escaped below using the ^ caret.


Code: Select all

 > C:\mytext.txt Echo.      SYSOPTS="'DSN=OPO.NDMD.SUBMIT(PEGFIS00),DISP=SHR', -
>> C:\mytext.txt Echo. 'PARM1 '~'^&FAF'~''"


When the redirection is at the start of the line you don't need an extra space at the end of every line.

phlex7
Posts: 5
Joined: 03 Aug 2014 07:53

Re: How to output 1 Double Quote to a text file

#3 Post by phlex7 » 03 Aug 2014 09:10

You are correct sir.

Setting the redirect at the beginning of the line works!!
The structure for the output to txt is intact and there are no errors.

There was an error using the & in the variable, however, I'm able to replace that.(see below)
Thank you!

> c:\bank\mytext.txt Echo. SYSOPTS="'DSN=OPO.NDMD.SUBMIT(PEGFIS00),DISP=SHR', -
>> c:\bank\mytext.txt Echo. 'PARM1 '~'%PB%'~''"

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to output 1 Double Quote to a text file

#4 Post by foxidrive » 03 Aug 2014 09:21

That's good.

Be aware that an & in a normal environment variable will still cause a problem, without special escaping or double quoting.

phlex7
Posts: 5
Joined: 03 Aug 2014 07:53

Re: How to output 1 Double Quote to a text file

#5 Post by phlex7 » 03 Aug 2014 09:26

Noted.

Thanks again foxi

phlex7
Posts: 5
Joined: 03 Aug 2014 07:53

Re: How to output 1 Double Quote to a text file

#6 Post by phlex7 » 14 Aug 2014 09:56

Just as stated.. I'm having issues with the &.

There was mention of special escaping? how would that work to achieve this output &INFILE="%1" to my .TXT?

Sample below...
>> D:\Vision\Bank\CHILBDUB\EDS\Command\PMT%PD%%PF%.CDP Echo. &INFILE="%1"

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: How to output 1 Double Quote to a text file

#7 Post by Squashman » 14 Aug 2014 11:24

Precede it with a caret.

phlex7
Posts: 5
Joined: 03 Aug 2014 07:53

Re: How to output 1 Double Quote to a text file

#8 Post by phlex7 » 15 Aug 2014 06:37

That did it. Thanks!

Post Reply