Solved Split a long "string"?

Dell / LATITUDE D610
April 28, 2012 at 18:02:49
Specs: Microsoft Windows Server 2003 R2 SP2, 2.01GHz / 1GB

I am using cURL in a FOR loop to fetch some data from a website. I believe I am
running into this problem: Command prompt (Cmd. exe) command-line string limitation.

In a debugging effort, I piped the cURL output directly to a file before trying the
same command in the FOR loop and found the line of data I want to parse is
8,271 characters long.

Where I am getting stuck:

FOR /F "skip=348 tokens=* delims=" %%B IN ('curl -s --url "%url_base%/%url_speech%=%1"') DO (
    SET html_line=%%B

With ECHO ON, these are the last few lines before the command window
goes bye-bye:

Sat 04/28/2012     
18:05:31.27   =>FOR /F "skip=348 tokens=* delims=" %B IN ('curl -s --url ""') DO (
SET html_line=%B  
 SET html_line=!html_line:"='!  
 SET html_line=!html_line:?=+!  
 SET html_line=!html_line:&=and!  
 SET html_line=!html_line:<= "[!  
 SET html_line=!html_line:>=]" !  
 SET html_line=!html_line:"[a]"=!  
 SET html_line=!html_line:"[b]"=!  
 SET html_line=!html_line:"[div]"=!  
 SET html_line=!html_line:"[p]"=!  
 SET html_line=!html_line:"[span]"=!  
 SET html_line=!html_line:"[/a]"=!  
 SET html_line=!html_line:"[/b]"=!  
 SET html_line=!html_line:"[/body]"=!  
 SET html_line=!html_line:"[/form]"=!  
 SET html_line=!html_line:"[/object]"=!  
 SET html_line=!html_line:"[/p]"=!  
 SET html_line=!html_line:"[/param]"=!  
 SET html_line=!html_line:"[/script]"=!  
 SET html_line=!html_line:"[/span]"=!  
 SET html_line=!html_line:"[/table]"=!  
 SET html_line=!html_line:"[/td]"=!  
 SET html_line=!html_line:"[/HTML]"=!  
 SET html_line=!html_line:  = !  
 SET html_line=!html_line:"[/div]" "[/div]"="[/div]"!  
 ECHO B HTML line = !html_line!  

Sat 04/28/2012     
18:05:32.05   =>(

Any ideas on how to get around this limitation? I checked the cURL manual to
see if there were a way to limit what is returned, and thought "--range" would
work for me, but it appears the site I'm querying does not honor that feature. I'm
thinking if I pipe the (cURL) output to a file, I would still have the string length
limitation problem.

When your only tool is a hammer, every problem looks like a nail.

See More: Split a long "string"?

Report •

April 28, 2012 at 20:28:59
Sorry 'bout that, it's the ol' allergies actin' up again.

How To Ask Questions The Smart Way

Report •

April 29, 2012 at 09:59:09
I hope you feel better Razor.

I ended up finding a pattern in the data, and was able to "tokenize" the output to get
the string split into two "compliant" smaller parts:

FOR /F "skip=348 tokens=14* delims=:" %%F IN ('curl -s --url "%url_base%/%url_speech%=%1"') DO (

When your only tool is a hammer, every problem looks like a nail.

Report •

April 29, 2012 at 10:51:51
✔ Best Answer
Oh, don't mind me. It happens whenever someone tries to pound screws with a hammer.

How To Ask Questions The Smart Way

Report •
Related Solutions

Ask Question