Solved

Pascal Dos Function Ping

Posted on 2004-04-29
2
288 Views
Last Modified: 2006-11-17
Hi everyone,
i'm making a program to ping a bunch of ip adresses, it's for a network, so i made a procedure to get the adresses to ping, and i know how to ping them via dos and so on ...

   SwapVectors;
   Exec(GetEnv('COMSPEC'), Commands^[i]);
   SwapVectors;

but i would like to know, if there is a way of knowing wether the ping did succeed, or if it did fail, i can't get that via DosError or DosExitCode,

i want my program to ping them and then give a logfile with the pings that did succeed, the ones who did not succeed and so on
can someone help me ou of that ?
thanks to anyone in advance

Elvis
0
Comment
Question by:Elvis1
2 Comments
 
LVL 6

Accepted Solution

by:
MannSoft earned 75 total points
ID: 10952961
You could try piping the output of the ping command to a text file, and then you could parse the file to determine if it succeeded or failed.  So the code might look like:

  SwapVectors;
  Exec(GetEnv('COMSPEC'), Commands^[i] + ' >> TEMP.TXT');
  SwapVectors;
  // Here you should call a function to read TEMP.TXT and determine the results
  // And then you should delete the temp file

The hardest part here will be writing the function to parse the file, but it shouldnt be too bad.  Just check each line for "Reply from" or whatever string is used when a ping fails.  If it doesn't find either, then just ignore that line.  If it finds one or the other, then that's a line you can use to determine if the ping succeeded.
0
 

Author Comment

by:Elvis1
ID: 10962937
Thanks A Lot, it's i great,
thank you verry much

Elvis1
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Fine Tune your automatic Updates for Ubuntu / Debian
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now