# Notifying via Terminal in Linux

**URL:** <https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640>\
**Category:** Ruby\
**Created:** [January 15, 2010, 2:39am UTC](https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640 "2010-01-15T02:39:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thinkwritemute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@thinkwritemute](https://www.ruby-forum.com/u/thinkwritemute)\
**Post date:** [January 15, 2010, 2:39am UTC](https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640/1 "2010-01-15T02:39:07Z")

</div>

So I’ve got this idea for a linux CLI program, and one of the things I  
want the program to do is notify Users of an event via the terminal.

Is there something out there I can use to do this? I was thinking of  
using the WALL command, but that seems sloppy and requires reading from  
a file (for ubuntu).

---

<div class="post-metadata">

**Author:** ![thinkwritemute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@thinkwritemute](https://www.ruby-forum.com/u/thinkwritemute)\
**Post date:** [January 15, 2010, 2:47am UTC](https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640/2 "2010-01-15T02:47:39Z")

</div>

El Viernes, 15 de Enero de 2010, Kurtis Rainbolt-greene escribiÃ³:

> So I’ve got this idea for a linux CLI program, and one of the things I  
> want the program to do is notify Users of an event via the terminal.
> 
> Is there something out there I can use to do this? I was thinking of  
> using the WALL command, but that seems sloppy and requires reading from  
> a file (for ubuntu).

WALL command doesn’t require reading from a file, it reads the STDIN.

When you do “wall \< FILE” you are redirecting the STDIN to the file, so  
the  
content of the file is passed to wall via STDIN.

When you run “wall” (just “wall”) you must insert text with the keyboard  
and  
press Ctrl+D to exist and deliver the message.

So in Ruby you could redirect the STDIN (better $stdin) to invoke the  
system  
command (not sure now how to achieve it but sure it’s possible).

---

<div class="post-metadata">

**Author:** ![thinkwritemute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@thinkwritemute](https://www.ruby-forum.com/u/thinkwritemute)\
**Post date:** [January 15, 2010, 3:04am UTC](https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640/3 "2010-01-15T03:04:02Z")

</div>

> press Ctrl+D to exist and deliver the message.
> 
> So in Ruby you could redirect the STDIN (better $stdin) to invoke the system  
> command (not sure now how to achieve it but sure it’s possible).

Yes, use popen3 to get a reference to stdin of the wall process and  
write into the stdin. Should work anyway…

-Jonathan N.

---

<div class="post-metadata">

**Author:** ![thinkwritemute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@thinkwritemute](https://www.ruby-forum.com/u/thinkwritemute)\
**Post date:** [January 15, 2010, 10:18am UTC](https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640/4 "2010-01-15T10:18:18Z")

</div>

El Viernes, 15 de Enero de 2010, Jonathan N.  
escribió:\> \> and press Ctrl+D to exist and deliver the message.

> > So in Ruby you could redirect the STDIN (better $stdin) to invoke the  
> > system command (not sure now how to achieve it but sure it’s possible).
> 
> Yes, use popen3 to get a reference to stdin of the wall process and  
> write into the stdin. Should work anyway…

With popen4 you also get the correct exit status code of the command 🙂

---

<div class="post-metadata">

**Author:** ![thinkwritemute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@thinkwritemute](https://www.ruby-forum.com/u/thinkwritemute)\
**Post date:** [January 15, 2010, 6:43am UTC](https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640/5 "2010-01-15T06:43:10Z")

</div>

Kurtis Rainbolt-greene wrote:

> So I’ve got this idea for a linux CLI program, and one of the things I  
> want the program to do is notify Users of an event via the terminal.

I think this utility already exists: syslog. It can also output certain  
messages to the terminal.

---

<div class="post-metadata">

**Author:** ![thinkwritemute](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58956e/32.png) [@thinkwritemute](https://www.ruby-forum.com/u/thinkwritemute)\
**Post date:** [January 15, 2010, 2:44pm UTC](https://www.ruby-forum.com/t/notifying-via-terminal-in-linux/181640/6 "2010-01-15T14:44:02Z")

</div>

Hello Kurtis,

2010/1/15 Kurtis Rainbolt-greene [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> So I’ve got this idea for a linux CLI program, and one of the things I  
> want the program to do is notify Users of an event via the terminal.
> 
> Is there something out there I can use to do this? I was thinking of  
> using the WALL command, but that seems sloppy and requires reading from  
> a file (for ubuntu).

If your program is intended to be run from the command-line, why a  
simple “puts” would not be enough ? It will naturally write to STDOUT  
which is the terminal that ran the command.

BTW, I don’t think that users will be pleased if your program write on  
_all_ their open terminals using wall. I usually have 16 of them open,  
each doing a different thing and a program that periodically write  
things on all of them will quite rapidly upset me.

Cheers,
