Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

help needed to write a batch file that test ping

- - - - -

  • Please log in to reply
6 replies to this topic

#1
chunhin

chunhin
  • Member
  • 1 posts
  • Joined 28-March 09
basically im new to writing command prompt batch files so really need help down here :thumbup

i need to write out a batch that can help me continously ping a ip address.
eg. ( ping 132.21.21.2 -t)

if during the pinging, there is request time out or destination host unreachable, the batch file will automatically net send to another computer ( which is in the same domain as mine ) to inform him that ping failed.
is it possible?


How to remove advertisement from MSFN

#2
rv31

rv31

    Newbie

  • Member
  • 35 posts
  • Joined 03-February 09
That is basically called a DOS attack,

http://en.wikipedia....-service_attack

#3
jcarle

jcarle

    MSFN Master

  • Developer
  • 2,559 posts
  • Joined 14-August 04
@rv31 : There's absolutely no Denial of Service in what he's doing. It's simply ping monitoring.

@chunhin : I'm not sure if it's possible to do what you'd like with a batch file, but some simple scripting in VBScript could do the trick. Take a look at this topic.
Posted Image
Posted Image

#4
jaclaz

jaclaz

    The Finder

  • Developer
  • 15,297 posts
  • Joined 23-July 04
  • OS:none specified
  • Country: Country Flag
A FOR /F should be all that is needed:
http://www.robvander...ntfortokens.php

Can you post the output of a "single" working "ping" and those with the "ping errors" that you want the alarm (redirection or whatever) to be triggered with?

Another VBS script that might be useful:
http://www.robvander...etwork_ping.php

jaclaz

#5
AO3

AO3

    Junior

  • Member
  • Pip
  • 87 posts
  • Joined 30-January 08
One problem you will run into. You can get destination host unreachable if your network gets a lot of traffic, or the machine you are pinging gets to many request. Also, some A/V programs will think you are a hacker doing DOS if it is non stop pinging. I have been using a program called "Is it up" to monitor cpu's and devices.

Edited by AO3, 14 April 2009 - 01:17 PM.


#6
HighDarkTemplar

HighDarkTemplar

    Member

  • Member
  • PipPip
  • 106 posts
  • Joined 20-January 05
You COULD try this one: "ping google.com -t".................

#7
SenHu

SenHu
  • Member
  • 5 posts
  • Joined 06-April 09
Are you allowed to use anything other than command prompt ? That will make parsing of the output easier.

Here is a possible script.

# Script ping15sec.txt
var str output, lost
while (true)
do
	# Ping. Collect output into variable $output.
	system "ping 132.21.21.2" > $output
	# Get the lost packect count. It is after "Lost =" in $output.
	stex -c -r "^Lost;=;^[" $output > $lost
	stex -c -r "[^,^" $lost > null

	# $lost must be "0". If not, something went wrong.
	if ($lost <> "0")
	do
		# Do something to report error here. For now, we will just shout.
		echo "LOST " $lost " PACKETS AT TIME " gettime()
	done
	endif

	# Sleep for 60 seconds
	sleep 60
done


Save the script in file C:/Scripts/ping15sec.txt, start biterscripting ( http://www.biterscripting.com ), enter the following command.

script "C:/Scripts/ping15sec.txt"





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users