LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   sending broadcast message in c (http://www.linuxquestions.org/questions/programming-9/sending-broadcast-message-in-c-123281/)

raven 12-06-2003 12:22 PM

sending broadcast message in c
 
hello

i would like to send a broadcast message to every shell connected to my linux box trough a c program. Just the way when you do a "shutdown -h now" when every x-terminal and shell says to you, that the system will be halted.

How do I do this?

Thanks

raven

jim mcnamara 12-06-2003 01:55 PM

Code:

system("shutdown -h now");
is far easier than any other approach.

You can also use wall just to send messages
Code:

char *mymessage={" 'Hello.' ");
char buf[256];
strcpy(buf,"wall ");
strcat(buf,mymessage);
system(buf);



All times are GMT -5. The time now is 11:12 PM.