Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: repl help  (Read 3210 times)

0 Members and 1 Guest are viewing this topic.

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
repl help
« on: July 28, 2014, 08:16:15 AM »
So I started to really use repl, and It's made quite a few of my scripts run infinitely smoother.  I'm running into some issues though.  I'm attempting to gather Lat / Long coordinates from a .kml file (looks quite a lot like html to me).  The issue that I've run into is that all the data in the kml is on the first line.  to correct this, I was trying to use repl to add new line characters at specific places to allow me to gather the necessary information using a for loop.  But for some reason, repl is erroring when I try.

Code: [Select]
T:\job>type "Cars French 1.kml" | repl X I "<address^>" "\n<address^>" >[f].txt
The syntax of the command is incorrect.
The syntax of the command is incorrect.
C:\cmdPlugins\repl.bat(191, 1) Microsoft JScript runtime error: Syntax error in
regular expression

The process tried to write to a nonexistent pipe.

T:\job>type "Cars French 1.kml" | repl X I "<address>" "\n<address>" >[f].txt
| was unexpected at this time.
The process tried to write to a nonexistent pipe.

Code: (Example kml) [Select]
<?xml version="1.0"?><kml xmlns="http://earth.google.com/kml/2.0"><Document><name>Stuff</name><description> | Created with http://batchgeo.com</description><style id="0"><BalloonStyle><text><![CDATA[ <b>$[name]</b><br />$[address]<br />$[description]<br/><br/>$[geDirections] ]]></text></BalloonStyle></style><Placemark><name>Amerya (3S)</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)034700165 &lt;/div&gt;</description><Point><coordinates>29.918739595939,31.20009469878,0</coordinates></Point><address>24kM Cairo-Alex Desert Road Alexandria Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Amex Ragheb</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)01222101673 &lt;/div&gt;</description><Point><coordinates>32.687635261674,25.680906223415,0</coordinates></Point><address>Airport Road Luxor Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Anas lel Sayarat</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)01003422839&lt;/div&gt;</description><Point><coordinates>32.899830632474,24.088942749132,0</coordinates></Point><address>El Mante 2a El Senaeya El gedida Aswan Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Ara Mechanics</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)01111099909&lt;/div&gt;</description><Point><coordinates>31.340403435549,30.089174843937,0</coordinates></Point><address>48 Abdel Razik El Sanhory St. From Makram Ebid Madinet Nasr Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Arish (2S)</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)0683353853&lt;/div&gt;</description><Point><coordinates>33.80327807662,31.132096531236,0</coordinates></Point><address>El Farik Bahary Fouad Zikry St. Behind Samiramis Hotel Arish Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Asyut (Service Center)</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)0882289663&lt;/div&gt;</description><Point><coordinates>31.185925714141,27.178313572373,0</coordinates></Point><address>El Wady El Gedeed Desert Road Infront of El Manteaa El Ganobeya el askareya Asyut Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Asyut (2S)</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)0882289663&lt;/div&gt;</description><Point><coordinates>31.174390102815,27.195572765047,0</coordinates></Point><address>55 ElHelaly St. Asyut Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Auto Group</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)16441&lt;/div&gt;</description><Point><coordinates>31.205026080241,30.050752011337,0</coordinates></Point><address>26 El Nakhil Street Mohandsein Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Auto Group</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)16441&lt;/div&gt;</description><Point><coordinates>29.926686437909,31.198941618085,0</coordinates></Point><address>27 Hassan lbn Thabet Tanta Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Dokki Showroom</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Area:&lt;/span&gt;&amp;nbsp;Dokki&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Short Number:&lt;/span&gt;&amp;nbsp;12311&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)33388463/7&lt;/div&gt;</description><Point><coordinates>31.204727306108,30.043222977757,0</coordinates></Point><address>40 Nadi EL Sayd St Giza Egypt</address><styleUrl>#0</styleUrl></Placemark><Placemark><name>Dokki Spareparts</name><description>&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Short Number:&lt;/span&gt;&amp;nbsp;12311&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;l&quot;&gt;Phone:&lt;/span&gt;&amp;nbsp;(+2)33358686&lt;/div&gt;</description><Point><coordinates>31.21457336134,30.042570120257,0</coordinates></Point>
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: repl help
« Reply #1 on: July 28, 2014, 09:35:08 AM »
There's  new version of repl.bat out which adds an extra N option to handle files with NULL characters correctly.

`repl.bat` (by dbenham) - download from:  https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

This addresses your error - there's no need to escape the > inside the quotes.

Code: [Select]
type "Cars French 1.kml" | repl "<address>" "\n<address>" xi >file.txt
and you might find this better for your usage:

Code: [Select]
type "Cars French 1.kml" | repl "(</.*?>)" "$1\n" xi >file.txt

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: repl help
« Reply #2 on: July 28, 2014, 10:03:14 AM »
I'm getting a "A device attached to the system is not functioning." error at lines 300 and 305.  Both at occurring when the script tries to run "WScript.Stdout.WriteLine(...)".  Any ideas?

Code: (Didn't Work) [Select]
type 1.kml | repl "address" "2address" mn
type 1.kml | repl "address" "\naddress" mxin
type 1.kml | repl "<address>" "\n<address>" mxin
type 1.kml | repl "<address>" "\n<address>" xin

Both 'type "Cars French 1.kml" | repl "(</.*?>)" "$1\n" xi >file.txt' and 'type "Cars French 1.kml" | repl "<address>" "\n<address>" xi >file.txt' returned files, but did not add the newline character.


EDIT: The last one added the newline char, but it only appears when viewing from preview in explorer.exe
EDIT 2: I managed to get it to work, but would still like to learn whats wrong.
« Last Edit: July 28, 2014, 10:50:48 AM by Lemonilla »
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: repl help
« Reply #3 on: July 29, 2014, 05:42:15 AM »
Both 'type "Cars French 1.kml" | repl "(</.*?>)" "$1\n" xi >file.txt' and 'type "Cars French 1.kml" | repl "<address>" "\n<address>" xi >file.txt' returned files, but did not add the newline character.

Yes, they do, but they don't add a CR and LF as I assumed you had a reason for using \n alone.

Change \n to \r\n and it will use normal Windows line endings.

Look at the output files in Winhex and you will see the 0A which is the \n character.

0A is the default line ending character for Unix/Linux, and Windows uses 0D 0A as the line ending characters, a Carriage Return and then a Line feed. 
The 0D is added by the \r in repl.

In an Apple system the line ending is just a 0D or it used to be.

The 0D 0A is hexadecimal notation for anyone not sure, and is shown as 13 10 in decimal ascii.
« Last Edit: July 29, 2014, 05:52:33 AM by foxidrive »

Lemonilla

    Topic Starter


    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: repl help
« Reply #4 on: July 29, 2014, 09:10:10 AM »
Thanks, I didn't know that. 
Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.