LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-04-2008, 01:34 PM   #1
vicky_brsh
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Rep: Reputation: 0
How to invoke sytem beep in Linux


Hi All,

I am newbie to Linux. i wanted to know how can i invoke system beeper after some instructions in my C++ program.

Example ---

#include <iostream>
using namespace std;

int main()
{
cout << "Hello world" << endl;
cout << "Hello world" << endl;

Beep() ; // Dont know which function to be used for beep

cout << "Hello world" << endl;
cout << "Hello world" << endl;

return 1;
}


Can any one help me to know if there is a way to invoke the beeper in Linux.

Thanks & Regards
Vikram
 
Old 09-04-2008, 03:22 PM   #2
armanox
Member
 
Registered: Sep 2005
Location: Baltimore, MD, USA
Distribution: Fedora, Gentoo, Debian, Slackware, IRIX, OS X
Posts: 192

Rep: Reputation: 32
Couple of ways to do this.

For your case the best thing to do is use the ASCII code for a beep.
You can add the beep with the following line of code:
Code:
cout << static_cast<char>(7);
Use that for your beep() function.

Or, make it the beep function
Code:
void beep()
{
static_cast<char>(7);
}
PS - I'm adding a new function to my library now...
 
Old 09-05-2008, 12:15 AM   #3
vicky_brsh
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Hi ArMonx,

Thank you for your reply. I am using Suse 10.3.
Here, printing '7' or '\a' is not workomg. Even if i execute beep command i am not able to get the beep sound. But if i press "CTRL + g" , I am seeing the bell symbol displayed on my terminal window.

Please let me know if i am missing any settings in Suse so that the bell will ring.

Thnaks & Regards
Vikram
 
Old 09-05-2008, 12:41 AM   #4
armanox
Member
 
Registered: Sep 2005
Location: Baltimore, MD, USA
Distribution: Fedora, Gentoo, Debian, Slackware, IRIX, OS X
Posts: 192

Rep: Reputation: 32
I remember not having the system beep on systems that produce the beep through the sound card instead of an actual system speaker. I also sorta remember there being a setting in the KDE 3 Control Center under Sound Administration regarding the system beep. No idea for you if you're running GNOME. Does your system have an actual speaker jsut for the beep?
 
Old 09-05-2008, 01:24 AM   #5
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 136Reputation: 136
Not all motherboards have a "beeper". Even if yours has it, special kernel module (I forgot it's name) should be loaded in order to make (char)\7 beep.
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl question: Anyway to invoke Linux commands... STAGED Programming 8 02-03-2006 12:57 PM
Invoke kickstart installation from Linux shell jeff99chapman Red Hat 2 10-26-2005 11:14 AM
is this sytem good/bad 4 linux chantaspell Linux - Laptop and Netbook 3 06-24-2004 09:22 PM
how to invoke a linux command inside a java code ? kusum Linux - Software 2 11-23-2003 01:19 PM


All times are GMT -5. The time now is 09:38 AM.

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