|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hey can anyone spot what I am doing wrong here? I want to have the user enter the starting and ending last three digits of an IP address in a certain subnet, then the Batch will go out and ping everyhting between those two numbers. Any help?
@ECHO OFF :main IF EXIST C:\PING_RESULTS.txt DEL C:\PING_RESULTS.txt ECHO Ping Test Ran on %date% at %time% >> C:\PING_RESULTS.txt ECHO. goto getips :GETIPS ECHO Enter Range of IP's to Ping in the 192.168.1 subnet ECHO. SET /P first="Please enter the first number in the range of IP addresses: " SET /a A=%first% SET /P second="Please enter the last number in your range of IP addresses to ping: " SET /a B=%second% Echo Results for ping test between 192.168.1.%A% and 192.168.1.%B% are as follows: >> C:\PING_RESULTS.txt goto ping ingECHO. ping -a 192.168.1.%A% >> C:\PING_RESULTS.txt IF %A%==%B% GOTO FINISH ELSE %A%=%A%+1 ECHO %A% GOTO PING :Finish set /p yes=Would you like to ping any more addresses (y/n)? if %yes%=y goto GETIPS ELSE goto end :end START Notepad.exe C:\PING_RESULTS.txt |
|
|||
|
Alternate Method
I see what you are trying to do, and I think my batch file does basically the same thing. Try it out and edit it to meet your needs.
Basically all this does is ping the specified range of IP addresses and returns only replies in a results.txt file. Since its a batch file, it takes long as hell to finish but it gets the job done. I would like to also have it create several 'threads', i.e. separate batch files that all work independently to ping the specified range, but not quite sure how do do it, as you can't append a line such as Code:
for /L %%X in (%S%,1,%E%) do echo %A%.%1%%X >>IPs >>thread3.bat If anyone has any ideas on how to do it, let me know. Code:
@echo off del IPs del temp cls ::Append Header to Results File if exist Results.txt ( echo. >>Results.txt echo --------------------------------- >>Results.txt echo. >>Results.txt ) if not exist Results.txt ( echo +-------------------------------+ > Results.txt echo ¦ IP Pinger by BeRsErKeR ¦ >>Results.txt echo +-------------------------------+ >>Results.txt echo. >>Results.txt echo Test Started on %date% at %time%. >>Results.txt echo. >>Results.txt echo. >>Results.txt ) ::Define Variables set S=1 set E=254 ::Get Range to Ping set /p A=Enter the first 3 octets of the IP address (e.g. 192.168.1): set /p S=Enter the starting range (1 to 254) (Enter for 1): set /p E=Enter the ending range (1 to 254) (Enter for 254): cls ::Create IP List File for /L %%X in (%S%,1,%E%) do echo %A%.%1%%X >>IPs ::Ping IP's in Generated File for /f "tokens=1" %%p, in (IPs) do ( echo Pinging %%p ping -n 1 %%p > temp findstr /C:"Reply from" temp >> Results.txt ) ::Cleanup Temp Files del IPs del temp ::Show Results Start Results.txt exit It seems to me that you want to log all results regardless of successful or not, so in that case you can change line Code:
findstr /C:"Reply from" temp >> Results.txt Code:
findstr "timed Reply" temp >> Results.txt Code:
echo %%p >> Results.txt Hope this is help to some of you ![]() |
|
|||||
|
In case you are interested. Here's what it looks like in WSH:
vb Code:
Code:
Ping Test Ran on 7/26/2008 at 8:26:48 PM Results for ping test between 192.168.1.0 and 192.168.1.10: 192.168.1.0 Failure 192.168.1.1 Success 192.168.1.2 Failure 192.168.1.3 Failure 192.168.1.4 Success 192.168.1.5 Failure 192.168.1.6 Failure 192.168.1.7 Failure 192.168.1.8 Failure 192.168.1.9 Success 192.168.1.10 Failure
__________________
Click the image if at any point you don't like my decision.10011100011000101111100011100000011000000100000011 10010011011110110001101101011011110100011000001110 0100111101000100001 Visit Nilpo.com and Ask the Windows Guru! Open me for some very useful links!
![]() Last edited by Nilpo : July 26th, 2008 at 07:28 PM. |
![]() |
| Viewing: Dev Hardware Forums > SOFTWARE > Programming > Batch File Help?!? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|