Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 09-10-2008, 11:04 PM   #1
LQ Newbie
Registered: Jun 2006
Posts: 24

Rep: Reputation: 15
terminate 'ping' without using ctrl-c

hello there!!

Im doing a code for 'ping' command.
can anyone tell me how to terminate the 'ping' process without using the ctrl-c.

I mean is there any way that we can define/fixed the send packet in 'ping'?

anyway, this is my code look like
#include <iostream>
#include <string>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>

using namespace std;

static string host;
static string ping_2;

void ping()
     cout << "Host: ";
     cin >> host;
     system (("ping " + host).c_str());
     cout << endl;
     cout << "Ping another host? Yes or No: ";
     cin >> ping_2;
     if (ping_2 == "Y" || ping_2 == "y")
     else if (ping_2 == "N" || ping_2 == "n")

int main()
attention from anyone will really appreciate
Thanks in advance!
Old 09-10-2008, 11:27 PM   #2
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
Can't you use the -c [number of packets] option?
Old 09-10-2008, 11:50 PM   #3
LQ Newbie
Registered: Jun 2006
Posts: 24

Original Poster
Rep: Reputation: 15
did u mean ping -c[num of packet] at the terminal console?
Old 09-11-2008, 12:15 AM   #4
LQ Newbie
Registered: Jun 2006
Posts: 24

Original Poster
Rep: Reputation: 15
ok! i got it!

im using the 'ping -c 4' and it works..
thanks alots!!
Old 09-11-2008, 12:47 AM   #5
Senior Member
Registered: Feb 2003
Location: Calif, USA
Distribution: Debian Wheezy
Posts: 2,842

Rep: Reputation: 48
I will apologize in advance, but as much as some people like to complain about an RTFM response, simply checking "man ping" ( SYNOPSIS ping [-dfnqrvR] [-c count] [-i wait] [-l preload] [-p pattern] [-s packetsize] ) would have answered this question.

Perhaps consulting the manual pages would answer the next question too.

No offense to tga in particular.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
KDE 3.5.9 - Konqueror - keyboard shortcuts ctrl+, and ctrl+. sometimes stop working bhy Linux - Desktop 1 07-26-2008 12:48 PM
ctrl-c to terminate a process does not work geek1234 Linux - Newbie 1 12-26-2007 03:34 PM
Any way to create bash short cuts (like CTRL+l for clear and Ctrl+D for exit) supersubu123 Linux - General 5 05-30-2007 04:02 AM
ctrl+c & ctrl+v equivalent for Gnome terminal window? halfpower Linux - General 2 11-29-2005 03:57 AM
no ctrl-a or ctrl-z in emacs or on command line? ashlock Fedora 5 12-30-2003 09:00 PM

All times are GMT -5. The time now is 08:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration