simple program for Ping

August 14, 2009 at 07:50:58
Specs: Windows XP, 1G
hello all,

is their any simple program in which i can ping different IP addresses like a batch file?

like for example, i want to ping 64.233.189.104, as well, 216.128.29.26, and 65.200.204.204. instead that i will wait for 64.233.189.104 to return to C:\> line or prompt, it will just continue to ping the next IP address and the next IP address.

all i need to see is the continuity of its replies or results of ping that it has a consistent of flows like 20-intervals before the next IP address. then it will run in command prompt like a batch file, and will toggle repeat to the very beginning IP address after the last IP address was run. perhaps i can also stop it anytime in between like Ctrl+Z.

its like a loop or simple cycle. i just plan to put it in my desktop so i can manage it to run easily.

i found a scenario that sounds like this thread that uses @echo:


http://malektips.com/xp_dos_0025.html


i'm not just familiar w/ programming or i just don't have the knowhow what's follow next.

i appreciate any help or assistance on this thread.

cheers!

let's build bridges, and not walls :)


See More: simple program for Ping

Report •


#1
August 14, 2009 at 08:53:21
Make a myping.bat file with the following commands...

Start:
@echo off
ping 64.233.189.104 -n 25 > log.txt
ping 216.128.29.26 -n 25 >> log.txt
ping 65.200.204.204 -n 25 >> log.txt
Goto:Start

Change the 25 with the number of pings you want to send.

Also you may want to use this...

http://www.eusing.com/ipscan/free_i...

Its like NMAP but not crazy impossible to use. I use it all of the time to monitor my system health.


Report •

#2
August 14, 2009 at 11:07:20
hi ace_omega :)

so i'll encode or type that script in a win XP Notepad then save it as a text file and later change the its extension to .bat?

actually, i'm planning that if i save it in text file then later change to .bat file ... i'll saved it in my desktop so i can quickly click on it.

so u can instruct me where to save the said file? and hoping it runs in command prompt.

thanks also for showing me the link. its very helpful.


cheers!

let's build bridges, and not walls :)


Report •

#3
August 15, 2009 at 23:22:51
Simply save as (whatever you want to name it).bat
Make sure to change "save as type" to "all files" in the save
popup. It will runn when you double click on it, and it will work
anywhere on your computer.

There are no stupid questions, just stupid people.


Report •

Related Solutions

#4
August 17, 2009 at 04:22:15
hello xterm11 and again to u ... ace_omega :)

i'm just wondering ... what is that log.txt means ,,, i mean does it logs all the IPs being ping?

likewise, can i subdivide the results in its command prompt window into two (2) ... like the name of the site being being is in the upper portion while its ping is on-going in the lower portion??


cheers!

let's build bridges, and not walls :)


Report •

#5
August 17, 2009 at 07:44:27
The log.txt is where its going to log the results of your ping.. I don't know how your proportioning your batch file. Please explain more. Unless someone else knows what your trying to ask.. cheeres


ALex


Report •

#6
August 17, 2009 at 12:15:42
hello way_2_hot_a a.k.a. ALex

how about if i don't need to log the results ... what would be the correct procedure?

likewise, i tried to run the said program and this is exactly what i get:


Windows cannot find ':'.Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search.


hoping anyone can elaborate, discuss, or explain farther :)


cheers!

let's build bridges, and not walls :)


Report •

#7
August 22, 2009 at 14:05:58
If all you want is a command window to stay open and show you the ping results a batch file like this would do what you like. Just save this in a notepad file and change the last part of it from .txt to .bat To stop a batch file from running just hit control-c, You can change the IP's and anything else, for help on what the -l and -n mean you can goto a command prompt and type "ping /?" without the quotes and it will display the help file for the ping command which will let you customize this exactly how you like, the reason I used -l 1 was to help minimize the network traffic 'cuase by default it sends a 32 byte ping.

So you know what is going on, @echo off, makes it so that the batch doesn't display the command that was entered, it just displays the results of the command.

The :batch is what they call a label, It allows you to use the goto command to goto different spots in a batch, obviously this batch is just using the label so that the goto command takes you back to the top of the list of ping commands there for creating a simple loop.

Earlier when everthing was going to a log file you can use > to port the results to a file which would make it easier in some instances like if you had a huge help file you wanted to read you could have that put into a text file like "ping /? > Ping.txt" would create a text file containing the help file for the ping command, and then the >> appends to a file so if you wanted added a line of text to the end of a text file you would just use >> to append it to the end of a file.

@echo off
:Begin
ping 64.233.189.104 -l 1 -n 25
ping 216.128.29.26 -l 1 -n 25
ping 65.200.204.204 -l 1 -n 25
Goto begin


Report •

#8
August 23, 2009 at 00:34:24
hello gtaion and good day as well ..

thanks really for the very enlightenment answer to my inquiries. i'm overwhelm by the response i got in this thread.

nevertheless, if the IP being ping is 64.233.189.104. the result then would look like this, and default ... the background is black in color and the font is white:

C:\>ping 64.233.189.104 -l 1 -n 25

Pinging 64.233.189.104 with 1 bytes of data:

Reply from 64.233.189.104: bytes=1 time=360ms TTL=244
Reply from 64.233.189.104: bytes=1 time=347ms TTL=244
Reply from 64.233.189.104: bytes=1 time=349ms TTL=244

Ping statistics for 64.233.189.104:
Packets: Sent = 13, Received = 13, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 258ms, Maximum = 398ms, Average = 329ms


i just want to change its color only of the IP address for quick identification. i know of that using Properties but usually its the whole line that is being change.

perhaps the portion only in italic is the prepared color to be change considering also that if their are many IP addresses so it can be blinding color in some instant.

hoping for farther guidance.


cheers!

let's build bridges, and not walls :)


Report •

#9
August 23, 2009 at 07:56:11
Conditional formatting is easy when you are using Microsoft Office, but unfortunately right off the top of my head I can not think of a good way to do it in a command prompt, Like you said, changing the text color normally changes all of the text in a window, if you goto the command prompt and type "color /?" you will get the help file on how to change the color, and obviously with that said it would be simple to change the color when you change IP addresses, but to change the color of the IP address it self, unless somebody knows a good way would use a couple loops with the "for" command and it might get a little complicated. So to change the color per IP it would look something like this, I know this is not what you are wanting but thats the easiest way to format color, as far as getting it to format how you were talking I'll think about it today and see what I can come up with, I'm hoping somebody comes up with something pretty simple

@echo off
:Begin
Color 0A
ping 64.233.189.104 -l 1 -n 25
Color 0b
ping 216.128.29.26 -l 1 -n 25
Color 08
ping 65.200.204.204 -l 1 -n 25
Goto begin


Report •

#10
August 23, 2009 at 10:27:02
Origanally when you said you wanted the IP address to be a different color I thought of ANSI encoding which back in the day was the cat's meow, you could get text to be colored or flashing or anything you wanted, So I was just gonna use a for /l loop to run a for /f loop to break down the ping command and then just echo the information back to you with the ANSI encoding so that it looked how you wanted, which isn't as hard as you would think, just read the for help "for /?" unfortunately after doing a quick google on why I couldn't get it to work, I found that winXP and Vista don't support ANSI anymore:( So unless you have an old computer that you are using or use some third party software, I don't think it is possible, I'm gonna keep a watch on this post, becuase I would love for somebody to prove me wrong. and teach us how to change the color of a single string of text in a command prompt. So the best I can come up with is what is posted in response 9 above, where it changes the whole windows color depending on which IP address it is pinging.

Report •

#11
August 24, 2009 at 09:27:03
hello there gtaion ..

& hope yur doin' good if not great today too. besides, i'm sure yur hands are all tied-up with all the inquiries u are gettin' daily basis. cheers though!

on the other hand, thanks really for the not just sweeping answers but very enlightening ideas u shared.

nevertheless, i did tried to follow yur steps in changing the color, and definitely it did change the color. however, everytime it goes to the next IP address, the whole text also changes :(

is their such a way like only those selected parts or items or under the code for the color will just change without affecting the other IPs?

afterall, i understand that above the IP addresses are its corresponding color assignment so i thought maybe it only needs like a page break.

sorry really for askin' u lots of things on these posts of mine and for being so persistent in my inquiries. i'm just a beginner with lots of enthusiasms to learn :)


cheers!

let's build bridges, and not walls :)


Report •

#12
August 24, 2009 at 09:43:09
If you refer to response 10, the only way I know of to format it the way you would like, no longer works if you are running a computer with either WinXP, Vista, Server03 or Server08 otherwise, if you are using an older system you could use ANSI encoding to set the formatted colors that you like. I'm hoping somebody comes accross this post and enlightens us on how to do it becuase the solution is beyond my current knowledge of Batch commands.

Report •

#13
August 24, 2009 at 12:03:10
hi gtaion ..

wow, u got me quick ... i mean u just answered my ques real time. cheers!

any way, i come across a link about 'color'. i just don't know how to apply them. here's the site:


http://ss64.com/nt/color.html


it say(s) something like:

The COLOR command will change the color of all the text in the window, to change individual lines or words you need to use PowerShell (Vista or Win XP) like this: Write-Host -ForeGroundColor Red "some text in red" -nonewline


i'm not sure if it can be integrated but i hope it will help especially in the said post of mine.

i'm glad yur always there for us the aspiring & enthusiastic learner :)


cheers!

let's build bridges, and not walls :)


Report •

#14
August 24, 2009 at 13:23:43
That is awesome, I haven't played around with powershell, but I have a broad over view of how it works. Unfortunately I won't have time this week becuase I will be out of the office doing some other things. Hopefully somebody else stumbles accross this post and enlightens us on PowerShell otherwise I'll take a look at it when I get a chance. I like it, I'm excited to jump into learning some powershell:)

Report •

#15
August 24, 2009 at 15:11:04
Okay so I started to play with some powershell and it's more like VBScript to me then DOS commands. But with that said if you create a .ps1 with the following, it will ping a list of IP's from a text file, every ten seconds and then display good pings in Green and bad ones in Red, works pretty spiffy, you can obviously change the sleep time if you like from 10 seconds to what ever if you want it to ping faster or slower, this will get you going, What I would like to do eventually when I get sometime to learn the differences between Powershell and VBscript is have your IP's set in an array built into the ps1 so that you don't need to have a text file of the IP or computernames.

$i=1
do {
$readfile=get-content "C:\list.txt"
foreach($readf in $readfile)
{
$ALive=get-wmiobject win32_pingstatus -Filter "Address='$readf'" | Select-Object statuscode

if($ALive.statuscode -eq 0)
{write-host $readf is REACHABLE -background "GREEN" -foreground "BLACk"}
else
{write-host $readf is NOT reachable -background "RED" -foreground "BLACk"}
}
Start-Sleep -s 10
}
while ($i=1)


Report •

#16
August 24, 2009 at 15:51:44
Okay so setting a dynamic array in powershell is not too different, just the way of adding to the array is different. If I were going to use powershell to do what you want this is how I would do it, To add more IP's or computernames to the array just simply add another line, since the array is dynamic it will grow as large as you want it to without having to change any other code. So here would be the .ps1 file that I would use with powershell. Remember control-c is the break command in powershell as well, so when you want to quit the loop just hit control-c

$i=1
do {
$arrcolComp=@()
$arrcolComp += "64.233.189.104"
$arrcolComp += "216.128.29.26"
$arrcolComp += "65.200.204.204"

foreach($Comp in $arrcolComp)
{
$ALive=get-wmiobject win32_pingstatus -Filter "Address='$Comp'" | Select-Object statuscode

if($ALive.statuscode -eq 0)
{write-host $Comp is REACHABLE -background "GREEN" -foreground "BLACk"}
else
{write-host $Comp is NOT reachable -background "RED" -foreground "BLACk"}
}
Start-Sleep -s 5
}
while ($i=1)


Report •

#17
August 24, 2009 at 16:32:12
hello gtaion and a very pleasant day to all :)

i initiated the syntax u recommended but its so quick i can't hardly see what's on it particularly yur Response Number 16 :(

nevertheless, i won't spoil yur activities as u said you'll be out from the 4-corners of yur room. in fact, i was so delighted and elated that no matter how hectic yur sched ... u still give importance to my post.

i'll just wait in yur return, and at the same time ... take time to ponder also to myself and perhaps study and practice more.


cheers!

p.s. have fun:)

let's build bridges, and not walls :)


Report •

#18
August 24, 2009 at 17:52:12
If it's just flashing by something is not right, First I don't know how computer savvy you are. But I'm hoping that you realize that the file extension for powershell is not a .bat but it is actually saved as a ".ps1" so by default if you double clicked it, it opens up in notepad for editing. Second by default powershell's security is set to restricted, which means if you've never run powershell before, it is probably still set to restriced which means it won't run any scripts at all. You can check it, if you open powershell and type "get-exectutionpolicy" without the quotes it will tell you how the secutrity is. If it is set to restricted you may want to set it to remotesigned, which would allow any script that you write to run, but scripts from the internet would need to be digitally signed. So if thats the case, I would suggest typing "set-executionpolicy remotesigned" next thing to do is, the security on running .ps1 files doesn't end there, to run it you need to type the fullname to the .ps1 file, so even if you had powershell open you need to type "c:\scripts\whereever\test.ps1" which sucks, I found for me the best way is to open powershell is to open powershell(Windows-logo key R) to get the run command then type powershell, it should open a window that looks like a DOS prompt, then I use the change directory command (CD) to navigate to the folder that contains the .ps1 file and run it by typing "./test.ps1" which still isn't as easy as just double clicking an icon. So what I would do is create a shortcut on the desktop to run the powershell script, Right click on your desktop goto new and choose shortcut, the new shortcut wizard will come up, for the location of the item you need to put the location of the powershell program with a space and then the location of the .ps1 you want to run, something like this %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\test.ps1
Then you should be able to just double click your link when you get to work in the morning and be good to go.

Report •

#19
August 25, 2009 at 09:54:59
hi gtaion ..

thanks goodness that even if yur hands are full, u can still take time to post an answer ... not just to this thread but also in other inquiries as i navigate through this site. cheers!

any way, i'll be honest that i'm not that computer savvy at all. i guess i'm just enthusiastic to learn stuff thats make me brought on this site.

nevertheless, i think yur right that one thing for sure the steps i've made didn't worked since it was still saved in .bat file. likewise, yur absolutely correct that i haven't run yet powershell in my PC.

however, i think it will not make my interest in continuing my objective in knowing how to change color per single-line or part only of results which u mentioned that it's VBScript to u than DOS commands.

i tried to execute those parameters "get-exectutionpolicy", as well, "set-executionpolicy remotesigned" in the Run under the Start in Win XP but it gets me a message that say(s) it doesn't exist in my PC :(

in addition, i followed "%SystemRoot%\system32\WindowsPowerShell\" but it can't be search either.


now, what should be lacking in my PC to have that powershell running and i can manage to input the data for the color to change?


perhaps that will be the starting point in-order the powershell to function well and make the file change from .bat to .ps1 which i haven't done yet.


cheers!

let's build bridges, and not walls :)


Report •

#20
August 25, 2009 at 16:08:19
Well I must say, it sounds like you don't have powershell installed on your computer. It's free from Microsoft and I believe if you are on an XP machine that it is an optional download from windows update website. If you are on a vista machine you have to choose to download it from the microsoft site.

http://www.microsoft.com/downloads/...


Report •

#21
August 25, 2009 at 17:27:30
hello again gtaion ..

i guess i'll look for the free download version of "Windows PowerShell 1.0 Installation Package for Windows XP" since i'm one of those who are using the unsupported installation of Win XP ;->

in fact, i'm hoping Microsoft is not reading on this reply of mine :)

however, if u or anyone can suggest a link that doesn't request for a genuine product ... it will be much appreciated.

and at any rate, i'll just update this thread most especially u, gtaion ... of this post the moment i have a copy of powershell.

it seems that i'm hook to this subject :)


cheers!

let's build bridges, and not walls :)


Report •


Ask Question