Computing.Net > Forums > Programming > Batch File Network Fault Diagnosis

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch File Network Fault Diagnosis

Reply to Message Icon

Name: h0me5k1n
Date: January 11, 2006 at 02:03:22 Pacific
OS: WinXP
CPU/Ram: 512
Comment:

I'm trying to create a batch file to ping a given IP address then, if this fails I want it to try pinging the same address but with .1 at the end of the ip instead. I can't work out how to set the variable to filter out the first three parts of the ip address to make xxx.xxx.xxx.1.

EXAMPLE: the batch file asks for an IP address, you enter 123.123.123.123. it tries to ping this address and, if this fails, it tries to ping 123.123.123.1.
I'd like the output of each ping recorded in a text file too (or the clipboard if possible).

Here's what I have so far:

@echo off

SET /P GIVENIP=Enter IP Address:

ping %GIVENIP% | findstr /I "Reply from" > nul 2>&1
if errorlevel 1 (
echo.%GIVENIP% - No response to ping.
pause
REM Try to ping .1 IP address here
)
else (
echo.%GIVEN% - Ping success!
)




Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: January 11, 2006 at 03:00:36 Pacific
Reply:

To parse and modify your IP address insert the following statement (that fits ONE line) that replaces the last token with 1

For /F "tokens=1-3 delims=." %%A in ("%GIVENIP%")Do Set GIVENIP=%%A.%%B.%%C.1


0
Reply to Message Icon

Related Posts

See More


sed ascii characters mystery char in redirecte...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch File Network Fault Diagnosis

Batch file network execution? www.computing.net/answers/programming/batch-file-network-execution/16014.html

Batch file to copy from network dri www.computing.net/answers/programming/batch-file-to-copy-from-network-dri/14488.html

Batch File that opens network drive www.computing.net/answers/programming/batch-file-that-opens-network-drive/11683.html