Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Use ping to check if ip is alive?

Posted on 1999-01-15
1
Medium Priority
?
1,996 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
[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
1 Comment
 
LVL 1

Accepted Solution

by:
chump earned 100 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

721 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