Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Run a command in a batch file

Posted on 2006-11-15
4
Medium Priority
?
738 Views
Last Modified: 2009-08-25
How can I run this command from a bat file and keep the window open (pause i guess) at the end?

for /L %a in (1,1,254) do @ping -n 1 -w 100 172.30.250.%a | find /i "reply"

TIA
0
Comment
Question by:ttist25
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Assisted Solution

by:Christopher McKay
Christopher McKay earned 1000 total points
ID: 17951946
Why would you want to keep the window open?

The command as it is doesn't display the info to the screen.

Is the desired end result to have a list of the IP Addresses that have "Reply" in the response?

If so, try this as your batch file:
@echo off
for /L %%a in (1,1,254) do (
     ping -n 1 -w 100 172.30.250.%%a |find /i "reply"
     if errorlevel=0 echo 172.30.250.%%a >>c:\results.txt
     )



The above will save all of the IP addresses that "reply" to a text file called results.txt in you c:\

Hope this helps!

:o)

Bartender_1
0
 
LVL 30

Accepted Solution

by:
callrs earned 1000 total points
ID: 17951947
Place this line into a batch file called, say "c:\temp\ping1.bat":

for /L %%a in (1,1,254) do @ping -n 1 -w 100 172.30.250.%%a | find /i "reply"

Then:
Start > Run > cmd /k c:\temp\ping1.bat

For more info, type this at the command prompt:
cmd /?

--
To simply pause, you could use the set command (type set /? for help):
set /p quit=Hit ENTER to continue
0
 
LVL 1

Author Comment

by:ttist25
ID: 17952860
Thanks guys!

I went ahead and created a batch file with the for statement and then dropped the cmd /k c:\pingall.bat in another bat file on the desktop.  
I was just hoping I could get it all together in one bat file.

In XP that command actually does display replies on the screen.  I tried it on a 2K server and it gave an error about not being able to find the file reply (or something like that).

I'm going to try your's on the 2k server bartender.

Thanks again!
0
 
LVL 30

Expert Comment

by:callrs
ID: 17953166
To get it into one file, and if all you need is a pause, instead of cmd /k you could use set /p which will hold the window open until you hit ENTER
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question