Jump to content

Batch - IP Finder (cleaning up a ping)

- - - - -

  • Please log in to reply
No replies to this topic

#1
Reece

Reece

    Newbie

  • Members
  • Pip
  • 1 posts
I'm looking to clean up my IP Finder... (I'm a beginner with Batch)

@echo off

TITLE IP Address Finder

echo Welcome to Reece's IP address finder!

echo.

echo.

ping -n 2 127.0.0.1>nul

echo How to use:

echo.

echo   1. Enter the desired URL.

echo   2. Press "Enter".

echo   3. You should see the message "Pinging (URL)".

echo   4. Look inside the brackets after the URL for the IP address of the website.

echo.

echo.

ping -n 2 127.0.0.1>nul

set/p "url=>"

ping -n 2 >nul

ping %url%

echo.

echo.

echo.

echo Press any key to exit.

pause>nul

I want to get rid of the messy-looking ping sequence, and leave the user with just an IP for the website they entered. Can this be done? Thank you! =)

EDIT:

A GREP parameter for a command "-O" may have something to do with it, not entirely sure.

EDIT 2:

Got it.
@echo off

TITLE IP Address Finder

echo Welcome to Reece's IP address finder!

echo.

echo.

ping -n 2 127.0.0.1>nul

echo How to use:

echo.

echo   1. Enter the desired URL.

echo   2. Press "Enter". 

echo.

echo.

set/p "url=> "

echo.

echo.

ping %url% | grep -o -m 1 \[.*\]

echo.

echo.

echo Press any key to exit.

pause>nul

Thanks anyway, people. =D Feel free to use this code for whatever you may need.

Edited by Reece, 09 June 2009 - 01:01 PM.
Added information





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users