Parse Field

  • Thread starter Thread starter Hank
  • Start date Start date
Thanks Mic. Can you explain this piece of code you're using:

2>&1 |find /i "INFO: No tasks">nul || (
goto :loop
)


">2&1" sends the STDERR stream to the same place that STDOUT is going.

In the above they will both be piped to FIND.

"||" and "&&" evaluate the errorlevel of the previous command and execute
the following commands. || executes on errorlevel 1 or higher and &&
executes on errorlevel 0.

In the above if the string is not found it will branch to the :loop label.

Or it should - I didn't test it.
 
I have a temp file (find.tmp) that contains the following string:

INW-SAM servername01 9999 3032 RUNNING Apr 27 17:22:07 2010

I'm trying to extract the 4th field, which is a PID, (3032) so I can
pass the PID to a kill process command. Below is the command I'm
using to trying to extract the data with:

for /f "tokens=4 delims=" %%G in (find.tmp) do @echo G: %%G


However, my logic (or lack of understanding of tokens) is wrong. Any
help is appreciated!
 
Back
Top