help needed w Windows batch script
Posted on 2016-07-16
I have in mind to write the following Windows batch script to poll entire range of 254 IP subnet to see
if the IP has web server listening on it; help me fix the codes below to get it working:
do while reading c:\temp\wgetoutput.txt
wget -S <IP_from_IPlist.txt> 2> c:\temp\wgetoutput.txt
if %errorlevel% == 0 then find "Server:" >> c:\temp\websvrtype.txt
echo "not a webserver" >> >> c:\temp\websvrtype.txt
I have the wget tool & it's tested working.
The error output (ie 2> ) of 'wget -S IP_addr' is as below:
If successfully connected to a web server: (ie errorlevel is 0)
Connecting to 10.1.10.71:80... connected.
HTTP request sent, awaiting response...
HTTP/1.0 301 Redirect
Date: Fri Jan 14 18:41:53 2106
If unsuccessfully connected to a web server: (errorlevel is usually 1 but can be high value if IP invalid; so all non-zero values)
Connecting to 10.1.10.1:80... failed: Connection refused.