Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Windows Batch file  (Read 2873 times)

0 Members and 1 Guest are viewing this topic.

Bharath M R

  • Guest
Windows Batch file
« on: November 16, 2010, 05:04:07 AM »
Hi all,
             I am very new to batch file programming.
i want to write a simple batch file which passes command like "snmpwalk <IP Range>"
on error it should be redirected to somefile , if successful it should'nt consider  and it shud go to next IP.


So finally i need only error giving IP's

Pls help


Thanks

Khasiar



    Intermediate

    Re: Windows Batch file
    « Reply #1 on: November 29, 2010, 05:10:04 AM »
    heres a batch i wrote a lil while ago, will ping 10.1.1.1-254 and output the ip's that are successful, you should be able to modify this to what you want


    @echo off
    set a=1
    :start
    ping -n 1 -r 4 -a 10.1.1.%a%
    echo %errorlevel%
    if %errorlevel% ==0 (ping -n 1 -r 4 -a 10.1.1.%a% >> a.txt) else (echo error 10.1.1.%a%)
    echo ------------ >> a.txt
    set /a a+=1
    if %a% == 255 goto end
    goto start
    :end
    pause
    exit