none
Batch File Page Lookup in a For Loop Jscipt Special Char Issue RRS feed

  • Question

  • 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 others with no luck. I can't change the #! as its automatically inserted and must be present.

    Any help would be greatly appreciated.

    • Moved by Bill_Stewart Friday, July 27, 2018 6:25 PM Unanswerable drive-by question
    Saturday, April 28, 2018 10:51 PM

All replies

  • Why do you think you can pass a string to a cscript call?  cscript only takes file names.

    cscript /?

    Usage: CScript scriptname.extension [option...] [arguments...]

    Note it requires a windows file name in the form of "scriptname.extension".

    Create "js" file that just echoes the URL back and see if it is sent correctly.

    The # character does not break a command line.  Only spaces, commas or semicolons would do this.


    \_(ツ)_/



    • Edited by jrv Saturday, April 28, 2018 11:11 PM
    Saturday, April 28, 2018 11:08 PM
  • Also your "SET" command is wrong:

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

    Quotes must not include var name.


    \_(ツ)_/

    Saturday, April 28, 2018 11:14 PM
  • This is interesting. This exact same script works fine when there is no #! in the URL.


    Sunday, April 29, 2018 2:15 AM
  • Poppycock.  We ca not guess at what you are doing.  My suggestions stand with any arguments or variables.

    We have no idea what is in your files and we cannot guess. 

    Generally speaking batch files are obsolete.  I recommend using PowerShell.  The JS files are also something we cannot guess at.

    Fix the syntax error I posted above.  Maybe that is causing your mysterious issue.


    \_(ツ)_/

    Sunday, April 29, 2018 2:27 AM
  • I fixed the syntax and realized I forgot to post the jscript along with script. Yesterday was a long day...

    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);

    I'm just grabbing the source code of the site.

    Sunday, April 29, 2018 1:06 PM