Quick Hack - Sending messages using BASH

This question comes from MrMasters who asked if there was a way to send messages between Raspberry Pis on the same network.

So I did a little Googling and found this little nugget on the Ask Ubuntu forums.

How can I send and receive a message?



To send a message to a remote computer, first the two need to connect up.

Setup the receiver

On one computer (receiver) I type in the Terminal

nc -l 55555

The -l switch instructs nc to wait for an incoming connection. And 55555 is the port to which the two machines connect and talk via. You can change the port number, but the sender and receiver must be on the same port.

Setup the sender

On a second computer (sender) type in the Terminal

nc IP ADDRESS OF FIRST MACHINE 55555

So for my demo the receiver machine has an IP address of 192.168.0.7

On the sender computer start typing your message!

Bit of fun



For fun (yeah I know) I piped the output of dmesg running on the sender machine to the nc command, so the receiver machine saw all the output from that command. Cool and could be handy for something!

dmesg | nc 192.168.0.7 55555

If you like what you read...

Would you like to buy me a cup of coffee? It helps me to pay for hosting this blog, and to buy stuff to hack from Poundshops / Dollar Stores which are used in free projects on this blog. Thanks!