Batch File: Ping Domain & get IP and show result with text -


situation

i have 2 email hosting lot of domain.

ej:
https://domain1.com hosted in server1 ip 1.1.1.1
https://domain2.com hosted in server2 ip 2.2.2.2
https://domain3.com hosted in server2 ip 2.2.2.2
https://domain4.com hosted in server1 ip 1.1.1.1

script function:

-the user input domain.
-the script yould ping domain, if domain ip 1.1.1.1 script should show (this domain hosted in "server1"). if domain 2.2.2.2 system show inform (this domain hosted in "server2").

@echo off setlocal enabledelayedexpansion set /p domain=ingrese domainname:  set server1=1.1.1.1 set server2=2.2.2.2  /f "tokens=1,2 delims=[]" %%a in ('ping -n 1 !domain!') (  if "%%b" neq "" set ip=%%b ) echo ip.....%ip%   if %ip% == !server1! echo server1  if %ip% == !server2! echo server2  pause 

problem:

i don't know this:

-if ip domain doesn't mach server1 or server2, said domain not mach.
-also if ip domain not resolved because not responce or doesn't exist, said domain doesn't exist.

use predefined variable:

echo ip.....%ip% set "srv=domain doesn't exist." if %ip% == %server1% set "srv=server1" if %ip% == %server2% set "srv=server2" echo %srv% pause 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -