![]() |
|
#1
|
|||
|
|||
How to invoke system beep in LinuxHi All,
I want to invoke the system beeper from Linux OS after executing few instructions in the code. Example CPP / C++ / C Code:
Can any one help me to know whether there is any system call available to do so? Last edited by admin : 04-Sep-2008 at 19:14.
Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
|
|||
|
#2
|
|||
|
|||
Re: How to invoke sytem beep in LinuxQuote:
The simplest thing that I can think of is to put the alarm special character '\a' to stdout. Depending on your system setup (what terminal program you are using and how it is configured), you just might hear it. See Footnote. CPP / C++ / C Code:
Output on my Centos system, using gnome-terminal with default installation setup: Code:
And, Indeed, I did hear a beep. It works for me, but since system hardware behavior is implementation-dependent, I hedge with my usual warning: Your Mileage May Vary. Regards, Dave Footnote: 0x07 is the keyboard equivalent to Ctrl-G. In ASCII tables, it's sometimes called "BEL" for "bell." Old mechanical teletype machines actually had a little bell, kind of like a bicycle bell, that was struck by a hammer when they received the BEL character. The idea was that a teletype operator (usually working alone in a small compartment in the bowels of a ship or some other isolated communications center) could could take a little nap, and when an important message came in, it might be preceded by one or more BEL characters to awaken him/her. The C standard (C++, too) defines '\a' as a special literal constant, but doesn't guarantee what its actual numerical value is. Also, the standards writers and compiler writers have no idea of whether your system will do anything special when a program puts '\a' to stdout, but the idea is that maybe, just maybe, the implementation-dependent part of the run-time library that gets linked into your program will so something meaningful if the hardware supports it. |
|
#3
|
|||
|
|||
Re: How to invoke sytem beep in LinuxHi Dave,
Thank you for quick reply. I tried printing '\a' to the STDOUT. But, i am not able to hear the beep. Can you please let me know if there is anything i shud do to enable the beep. I am using Suse 10 & 11 for testing of this functionality. Or even if it is on windows it is OK. Thanks & Regards Vikram |
|
#4
|
|||
|
|||
Re: How to invoke sytem beep in LinuxQuote:
If you compiled and executed my test program and heard nothing, then there's not much else that you can do with C or C++. It's a Hardware thing. Or an Operating System Sound System Setup Thing. Or something outside the control of C/C++. I don't have Suse. I have never had Suse. I don't imagine that I will ever have Suse (but it's possible, some day). Therefore, I can't walk you through sound setup stuff. That's what I meant by "Your Mileage May Vary." Sorry, Dave |
|
#5
|
|||
|
|||
Re: How to invoke sytem beep in LinuxQuote:
I don't know if this helps but: That little test program creates beeps on my Windows XP platform when I compile it with various Borland bcc32.exe compilers and with various Microsoft Visual C++ compilers, but not with a cygwin/g++ compiler. YMMV (but I said that already). Regards, Dave |
|
#6
|
|||
|
|||
Re: How to invoke system beep in LinuxIn Fedora 6 - fluxbox and gnome xterms and the tty console I'm getting a beep from either of these:
CPP / C++ / C Code:
|
|
#7
|
|||
|
|||
Re: How to invoke sytem beep in LinuxQuote:
An interesting update (interesting to me, that is): I don't routinely have speakers attached to my Windows PC, and I don't routinely listen to the headset plugged into my sound card. Why is that interesting to me? Well, as I mentioned, when I compile the program with various Borland and Microsoft compilers on my Windows XP platform, it plays the "beep" through the crummy little sound device on the motherboard. On the other hand: When I compile the little test program with GNU compilers on my XP box, it uses the sound card, and plays the system "Default Beep," which is the "Windows XP Ding.wav" file in the Windows\media directory. Since I wasn't listening to the headset when I ran the tests, I didn't hear it. That emphasizes the reason that I keep repeating my mantra for non-standard and, therefore, implementation-dependent, functions and functionality (all together now): Your Mileage May Vary. Regards, Dave Footnote: How the heck did they do that? Is it just possible that the cygwin port of the GNU tools is, in some respects, more sophisticated than "native" Microsoft tools? My flabber is, like, totally gasted! Last edited by davekw7x : 07-Sep-2008 at 15:34.
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [HOWTO] Belkin 54G Wireless card in linux (Broadcom chip) | dsmith | Computer Software Forum - Linux | 83 | 16-May-2008 14:17 |
| How To Remove Linux And Install Windows? | rockaway | Computer Software Forum - Windows | 3 | 06-Mar-2008 22:00 |
| Help Old Computer Linux Network Planning | 6795 | Computer Software Forum - Linux | 1 | 09-Dec-2007 22:56 |
| Question regarding EditBox control! | gopikomanduri | MS Visual C++ / MFC Forum | 0 | 12-Jun-2007 07:10 |
| Linux Kernel Upgrade Mini Howto | dsmith | Computer Software Forum - Linux | 3 | 05-Apr-2004 23:10 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The