0

I am trying to run this .bat script

set target_path =\\remoteserver\c$\newfolder\newfolder1\logs >log.txt
findstr /m "ERROR" "%target_path%\file1.txt" >> log.txt   

The expected output from this .bat file is that it will pick up "ERROR" string from file1.txt from the "remoteserver" and will show as output in log.txt.

But,once when i run this script it shows me the following error

FINDSTR: Cannot open \remoteserver\c$\newfolder ...

Kindly, suggest me the flaws or correct script so that the above script gets executed successfully with the expected output .


thanks for your quick update and sorry for acknowledging late. I tried executing the batch script with the necessary corrections you mentioned needed in the script , but still i face the same problem . I am unable to fetch the "ERROR" from log file and get the expected output. Is there any other field to be added to "FINDSTR" to pull up the ERROR ??.. Kindly, assist me for the same. Thanx in advance.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
ankit
  • 1
  • check out [UNC](http://en.wikipedia.org/wiki/Uniform_Naming_Convention#Uniform_Naming_Convention). – Endoro Jul 16 '13 at 13:58

1 Answers1

0

Not at all sure how you achieved that response given the scant 2 lines of code you've posted.

You are setting the variable "target_path ", not "target_path" according to your first line. Batch is sensitive to spaces in a set statement.

Since "target_path" is not set, it's a total mystery how your response is Cannot open \remoteserver\c$\newfolder ... unless the variable "target_path" had been previously set in the environment. The findstr should, with the posted code, have been executed against the file "\file1.txt" - not as reported.

Magoo
  • 77,302
  • 8
  • 62
  • 84
  • hi peter, thanks for your quick update and sorry for acknowledging late. I tried executing the batch script with the necessary corrections you mentioned needed in the script , but still i face the same problem . I am unable to fetch the "ERROR" from log file and get the expected output. Is there any other field to be added to "FINDSTR" to pull up the ERROR ??.. Kindly, assist me for the same. Thanx in advance. – ankit Jul 29 '13 at 15:03