:loop set file="netstat_hits.txt" netstat -ano | findstr 10.1.2.3 >> netstat_hits.txt netstat -ano | findstr ":80 " >> netstat_hits.txt FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA IF %size% NEQ 1 goto tasker ping 127.0.0.1 goto loop :tasker tasklist >> netstat_hits.txt goto loop
The file started out as one byte (I just put an "a" in it). If the netstat | findstr >> file combo worked, it would trigger the :tasker call to write the tasklist into the same file. Then I just periodically checked to see if the file was ever more than 1 byte big, and ctrl-c'd the batch script.
If someone knows of a better way of doing it, I'm all ears.
No comments:
Post a Comment