Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <stdlib.h>
- #include <unistd.h>
- using namespace std;
- int main(){
- string s,ip;
- for(int i=0; i < 5; i++){
- s="ping -c1 ";
- ip="10.6.15.";
- /////
- //
- int a= 111+i;
- //
- ///
- stringstream ss;
- ss << a;
- string str = ss.str();
- ip.append(str);
- s.append(ip);
- s.append(" > /dev/null");
- usleep(3000000); // micro sec
- int retval = system(s.c_str());
- cout<< ip << " .. " << ((retval==0)?"up":"down" ) << endl;
- }
- // 0 - success
- // 256 - packet lost either system down or ip not reachable
- // 512 - unknown host 0 < ip < 256
- return 0;
- }
Add Comment
Please, Sign In to add comment