Solved

Use ping to check if ip is alive?

Posted on 1999-01-15
1
1,971 Views
Last Modified: 2013-12-25
Hi!
  I have a C script using ping to check if an ip address is alive... i'm using this code:

  int result;
  result = system("ping -c 2 ipaddresshere");

but i can't get the correct value of result...

can you give me another way of making a C script so that it will view to me if an ip is alive through an html?

please help me!!!

Faceless
0
Comment
Question by:faceless
1 Comment
 
LVL 1

Accepted Solution

by:
chump earned 50 total points
ID: 1830689
Using some kind of Unix?
I'm using this with Linux:

int result;
result = system( "ping -c 2 ipaddress | grep -e '100% packet loss'" );

If ping is successful, result will be 256.
If all 2 ping packets get lost, the result is 0.

0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

713 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