Computing.Net > Forums > Programming > IP address in Batch files

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.

IP address in Batch files

Reply to Message Icon

Name: ndelgado57
Date: July 29, 2007 at 11:06:13 Pacific
OS: XP
CPU/Ram: PIII 256
Product: Dell
Comment:

Can some help me with a batch file that would
check weither Three network exist, and if one does execute a command after.

Example:

Check smtp.aol.com
check smtp.mint.com
check smtp.eva.com

Which ever it detects gets the commandline.

So far I have this

@echo off
ping smtplocal.nt.knr.kn >nul
IF ERRORLEVEL 1 GOTO AOL
IF ERRORLEVEL 0 GOTO KN



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 29, 2007 at 18:33:53 Pacific
Reply:

It looks okay so far. What's the problem?


0

Response Number 2
Name: Mechanix2Go
Date: July 30, 2007 at 00:39:00 Pacific
Reply:

This:

IF ERRORLEVEL x

tests for ERRORLEVEL x *OR MORE* so

IF ERRORLEVEL 0

will always be true.

better code:

IF ERRORLEVEL 1 GOTO AOL
GOTO KN

========================
What's not working?



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 3
Name: ndelgado57
Date: July 30, 2007 at 19:41:33 Pacific
Reply:

Thanks for even looking at this.

What's not working is my third option or is it not possible? Thanks again..

@echo off
ping smtplocal.nt.knr.kn >nul
IF ERRORLEVEL 1 GOTO AOL
IF ERRORLEVEL 0 GOTO mint
eva

:AOL

exit
:MINT

exit
:EVA

exit
end


0

Response Number 4
Name: Mechanix2Go
Date: August 2, 2007 at 04:44:08 Pacific
Reply:

Like I said "IF ERRORLEVEL 0" is always true. So it never gets to :eva


=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 5
Name: Balkrah (by Vaughan Newton)
Date: August 4, 2007 at 06:49:33 Pacific
Reply:

if you want to be exact use:

if %errorlevel%==x


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: August 4, 2007 at 07:02:00 Pacific
Reply:

That's no more exact, just different.

Same problem: you can't control 3 branches with 2 state logic.


=====================================
If at first you don't succeed, you're about average.

M2



0

Sponsored Link
Ads by Google
Reply to Message Icon






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: IP address in Batch files

Ip address in Batch Files www.computing.net/answers/programming/ip-address-in-batch-files/6571.html

batch file name date and time www.computing.net/answers/programming/batch-file-name-date-and-time/15060.html

Batch file to remote shutdown network PC's www.computing.net/answers/programming/batch-file-to-remote-shutdown-network-pcs/19105.html