mrprajesh

isipsup

Mar 22nd, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. using namespace std;
  6. int main(){
  7.     string s,ip;
  8.     for(int i=0; i < 5; i++){
  9.         s="ping -c1 ";
  10.         ip="10.6.15.";
  11.         /////
  12.         //
  13.         int a= 111+i;
  14.         //
  15.         ///
  16.         stringstream ss;
  17.         ss << a;
  18.         string str = ss.str();
  19.         ip.append(str);
  20.         s.append(ip);
  21.         s.append(" > /dev/null");      
  22.         usleep(3000000); // micro sec
  23.         int retval = system(s.c_str());
  24.         cout<< ip << " .. " << ((retval==0)?"up":"down" ) << endl;  
  25.     }
  26.     // 0 - success
  27.     // 256 - packet lost either system down or ip not reachable
  28.     // 512 - unknown host 0 < ip < 256
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment