Solved Batch file page lookup in a for jscipt special char issue

April 28, 2018 at 15:43:07
Specs: Windows 7
My batch file code is as follows:

set "URL=http://127.0.0.1:99999/site/index.html#!/page/999...lots of characters and numbers...999/data"

for /f "delims=" %%I in ('cscript /nologo /e:jscript "%~f0" "%URL%"') do (
>>"D:\Output\Data.txt" echo %%I
)

I believe the issue is the # or #! in the site address due to jscript and I have had no luck in coming up with a solution. I have tried many variations with %23 and such with no luck.

Any help would be greatly appreciated.


See More: Batch file page lookup in a for jscipt special char issue

Report •

#1
April 28, 2018 at 21:34:12
✔ Best Answer
Not sure why you're using cscript...

set "URL=http://127.0.0.1:99999/site/index.html#!/page/999...lots of characters and numbers...999/data"

for /f "delims=" %%I in ('cscript /nologo /e:jscript "%~f0" "%URL%"') do (
>>"D:\Output\Data.txt" echo %%I
)

So, you have URL set to:
http://127.0.0.1:99999/site/index.h...

But that item is not a jscript or cscript,, only a URL, so that leaves me scratching my head...

message edited by nbrane


Report •

#2
April 29, 2018 at 06:05:34
Yeah, I left out the important jscript part as I wasn't thinking clearly.

JScript */
var x=new ActiveXObject("Microsoft.XMLHTTP");
var nothing="BLANK";
x.open("GET",WSH.Arguments(0),true);
x.send('');
while (x.readyState!=4) {WSH.Sleep(50)};
var theCode=x.responseText
WSH.Echo(theCode);


Report •

#3
April 29, 2018 at 06:21:14
joeasmith: I believe the issue is the # or #! in the site address due to jscript
Probably not the issue. Jscript is smart enough to know its data from its commands, and will not go messing around with the data unless instructed. '#' has no special meaning in batch, and will be passed unaltered to the other script. '!' has no special meaning in batch, unless you have enabled delayed expansion, in which case, don't use delayed expansion, or replace any instance of '!' with '^^!'.

What I'm interested in is this line:

'cscript /nologo /e:jscript "%~f0" "%URL%"'
That would imply you're storing both scripts in the same file. If you are, and you really are just setting the %URL% to a static value, why not just keep the URL in the jscript part?

How To Ask Questions The Smart Way

message edited by Razor2.3


Report •
Related Solutions


Ask Question