I am trying to configure a web server using only batch scripts from Windows.
I already came up with the following script:
@echo off @setlocal enabledelayedexpansion for /l %%a in (1,0,2) do ( type tempfile.txt | nc -w 1 -l -p 80 | findstr mystring if !ERRORLEVEL! == 0 ( echo found > tempfile.txt ) else ( echo not-found > tempfile.txt ) )
However, the answer is always one request, I mean, if I enter something like this into the browser:
REQUEST: localhost/mystring
I will get the following answer:
RESPONSE: not-found
Only in the next request do I get the correct answer for the request presented above.
This is because as soon as netcat receives the request, it responds with the current contents of tempfile.txt, which is not yet updated based on the request.
Is there a way to block the response until tempfile.txt or any other method that achieves the expected result is updated?
windows webserver named-pipes batch-file netcat
utxeee
source share