Tom's Guide > Forum > Windows 2000/NT > Windows 2000/NT General Discussion > Problem with underscore in findstr literal string

Problem with underscore in findstr literal string

Forum Windows 2000/NT : Windows 2000/NT General Discussion - Problem with underscore in findstr literal string

TomsGuide.com: Over 800,000 questions and answers to address all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

Archived from groups: microsoft.public.win2000.general (More info?)

 

Hi

I've written a series of batch jobs, where one job writes into a log
file (success/failure) and the next one then checks to see if job1 was
successfull. The batch is to process a series of reports. I am using
the path to the report to find the right entry in the log file.

Now the path has changed and newly includes an underscore (_)
character. Since then, the findstr does not work as expected anymore. I
can find no reference that _ is some kind of special character. If I
escape the _ (manually, that is), the findstr works.

=== Script ===
set TARGETREPORT=\\vfbdn114\eglch$\_Projekte\MidOffice
Report\Testing\RC Energy per Book.xls
set STRING=%TARGETREPORT% Status: SUCCESS
findstr /c:"%STRING%" "c:\temp\Reports_20050709_085932.log"
IF %ERRORLEVEL% EQU 1 goto failure
IF %ERRORLEVEL% EQU 0 goto end
:failure
ECHO fail=%ERRORLEVEL%
:end
ECHO ok=%ERRORLEVEL%
== End Script ===

The complete string in the log file is

"09.07.2005 17:52:44 Report generation
\\vfbdn114\eglch$\_Projekte\MidOffice Report\Testing\RC Energy per
Book.xls Status: SUCCESS "

If I change the first line of the script to
set TARGETREPORT=\\vfbdn114\\eglch$\_Projekte\MidOffice
Report\Testing\RC Energy per Book.xls

Any ideas ?
Thanks

Sponsored Links
Register or log in to remove.

Archived from groups: microsoft.public.win2000.general (More info?)

 

On 9 Jul 2005 10:42:27 -0700, "borgulyp" <borgulyp@gmx.ch> wrote:

>Hi
>
>I've written a series of batch jobs, where one job writes into a log
>file (success/failure) and the next one then checks to see if job1 was
>successfull. The batch is to process a series of reports. I am using
>the path to the report to find the right entry in the log file.
>
>Now the path has changed and newly includes an underscore (_)
>character. Since then, the findstr does not work as expected anymore. I
>can find no reference that _ is some kind of special character. If I
>escape the _ (manually, that is), the findstr works.
>
>=== Script ===
>set TARGETREPORT=\\vfbdn114\eglch$\_Projekte\MidOffice
>Report\Testing\RC Energy per Book.xls
>set STRING=%TARGETREPORT% Status: SUCCESS
>findstr /c:"%STRING%" "c:\temp\Reports_20050709_085932.log"
>IF %ERRORLEVEL% EQU 1 goto failure
>IF %ERRORLEVEL% EQU 0 goto end
>:failure
>ECHO fail=%ERRORLEVEL%
>:end
>ECHO ok=%ERRORLEVEL%
>== End Script ===
>
>The complete string in the log file is
>
>"09.07.2005 17:52:44 Report generation
>\\vfbdn114\eglch$\_Projekte\MidOffice Report\Testing\RC Energy per
>Book.xls Status: SUCCESS "
>
>If I change the first line of the script to
>set TARGETREPORT=\\vfbdn114\\eglch$\_Projekte\MidOffice
>Report\Testing\RC Energy per Book.xls
>
>Any ideas ?
>Thanks

As an experiment change the findstr to
findstr /L /c:"%STRING%" "c:\temp\Reports_20050709_085932.log"

Reply to Anonymous
Tom's Guide > Forum > Windows 2000/NT > Windows 2000/NT General Discussion > Problem with underscore in findstr literal string
Go to:

There are 11 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Google ads