Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I trigger the "System Bell" in nodejs

I'm running a long running custom nodejs script and would like to be notified when the script is completed.

How do I make nodejs trigger the "System Bell"?

like image 476
DebugXYZ Avatar asked Dec 19 '11 05:12

DebugXYZ


People also ask

How do I use console commands in node JS?

Unit Testing and Test Driven Development in NodeJS Node. js console is a global object and is used to print different levels of messages to stdout and stderr. There are built-in methods to be used for printing informational, warning, and error messages.

What is Dispatch in node JS?

It facilitates interaction between objects in Node. A Dispatcher is a service object that is used to ensure that the Event is passed to all relevant Listeners.


2 Answers

Output the BELL character (Unicode 0007) to the standard output.

console.log('\u0007'); 

References

  • ASCII/ISO 8859 (Latin-1) Table

  • Unicode Characters: 00000 to 000FF

  • The Open Group Base Specifications Issue 7: Portable Character Set

  • Programming with Unicode Documentation (unicodebook.pdf)

  • How a bullet turns into a beep – The Old New Thing

  • Unicode 10.0.0 Final Names List

like image 151
Paul Sweatte Avatar answered Sep 21 '22 01:09

Paul Sweatte


The console.log('\u0007') didn't work for me running VSCode on windows 10. The following code did work:

import { exec } from 'child_process' exec(`rundll32 user32.dll,MessageBeep`) 
like image 36
Ronen Avatar answered Sep 18 '22 01:09

Ronen