Re: ^M characters in the files

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 03/17/04


Date: Wed, 17 Mar 2004 23:17:15 +1100

That's what windows text files look like in binary editors
such as 'vi' and 'gvim'.

Why did you begin a new thread ?

>From what O/S are these files you're parsing ?
What editor are you using ?

Cheers.
Chris Val

"madan" <anonymous@discussions.microsoft.com> wrote in message
news:368C3F44-558C-40FF-B0B8-35B600F4EB02@microsoft.com...
| Hello All:
|
| I would like to do token replacements in FileB using FileA. I was able to do this
(thanks to Steve). The script works fine. But the problem is once it writes to the file,
it is appending ^M character for every token that has been replaced. How do I fix the
problem? Any help is appreciated. I have enclosed the script at the end of the file.
|
| FileA:
| ====
| HOST_NAME = aaa.bbb.com
| PORT_NUMBER = 80
| INSTALL_LOCATION = c:\temp
|
| FileB:
| ===
| machine_name = HOST_NAME
| machine_ port = PORT_NUMBER
| install_location = INSTALL_LOCATION
|
| FileB looks like below after the script is executed:
|
| machine_name = aaa.bbb.com^M
| machine_ port = 80^M
| install_location = c:\temp ^M
|
| How do I get rid of the extra character in the script?
|
| Script:
| ==========================================================
| Const ForReading = 1, ForWriting = 2
| Set FSO = CreateObject("Scripting.FileSystemObject")
|
| With New RegExp
| .Pattern = "^(.*?) = (.*)$"
| .Multiline = True
| .Global = True
| Set Tokens = .Execute(FSO.OpenTextFile(FILE_A, ForReading, False).ReadAll)
| End With
|
| B = FSO.OpenTextFile(FILE_B, ForReading, False).ReadAll
|
| For Each Token In Tokens
| B = Replace(B, Token.Submatches(0), Token.Submatches(1))
| Next
|
| FSO.OpenTextFile(FILE_B, ForWriting, False).Write B
| ===========================================================
|
| Thanks in advance,
| Madan



Relevant Pages

  • ^M characters in the files
    ... machine_ port = PORT_NUMBER ... FileB looks like below after the script is executed: ... How do I get rid of the extra character in the script? ... For Each Token In Tokens ...
    (microsoft.public.scripting.wsh)
  • Re: ^M characters in the files
    ... "How do I get rid of the extra character in the script? ... > I would like to do token replacements in FileB using FileA. ... > For Each Token In Tokens ...
    (microsoft.public.scripting.wsh)
  • RE: Vista group policy, 2003 server...help ?
    ... Windows accomplishes this by using two ... access tokens for each user: ... limited and elevated tokens are mostly identical, ... The script actually works and maps the drive. ...
    (microsoft.public.windows.server.general)
  • Re: Mysterious MathInst error
    ... or in a place where tokens were being ... There seems to be a bug in the MathInst script which ... By the way, after running the script, I get everything as expected ... I wonder if anyone can tell me if my impression was wrong, ...
    (comp.text.tex)
  • Re: script for paypal
    ... >> ebook on my site ... >> The script should be on the server side that paypal calls when the ... >> and saves that token to my list of valid tokens. ...
    (alt.php)