Single quotes logparser

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Boddu Boddu 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34737
    Profile photo of Boddu
    Boddu
    Participant

    Hi

    i am searching a string in IIS Logs, i am parsing this through Logparser. The Logparser throws an error when ever the string has a single quotes with in it.
    sample code

    SELECT To_lowercase(cs-uri-stem) as URL, count(URL), MAX(Date)
    FROM '[LOGFILEPATH]'
    WHERE URL LIKE 'String's url' AND cs-username is not NULL
    GROUP BY URL

    the script works fine if the string has no single quotes in it. but i am not sure how can i make this work if it has a single quotes in the string. can anyone help me out?

    Regards
    Lokesh

    #34738
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    Quick search turned this up: http://forums.iis.net/t/1154802.aspx?Apostrophe+Excape+Need+in+Folder+Path+Using+Log+Parser+as+an+object+in+vbscript

    If that does indeed work, then you should be able to escape your strings with this bit of PowerShell:

    $someText = "This string's got an apostrophe in it."
    $someText = $someText -replace "'", '\u0027'
    
    #34749
    Profile photo of Boddu
    Boddu
    Participant

    it works dave

    Thankyou

    Regards
    lokesh

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.